[rspec-users] what's with the response.should_be_xxxx stacktrace?

Courtenay court3nay at gmail.com
Sat Dec 30 20:24:50 EST 2006


If I do

    get :index
    response.should_be_success

I get about 20k of marshalled dumpage that starts like

  #<ActionController::TestResponse:0x390443c @body=\"<html><body>You
are being <a href=\"http://test.host/carts/1\">redirected</a>.</body></html>\",
@assigns=[], @redirected_to={:action=>\"show\", :id=>1},
@template=#<#<Class:0x38d5fc4>:0x38d5f9c @assigns={\"template_ro

and finishes 20 pages later with

  @headers={"Status"=>"302 Found", "cookie"=>[],
"Content-Type"=>"text/html; charset=utf-8",
"Cache-Control"=>"no-cache", "location"=>"http://test.host/carts/1"},
@session=#<ActionController::TestSession:0x390466c
@attributes={"flash"=>{}, :cart=>{}}>> should be success nil

My question is, is this intended, or just a side-effect of using
should_be_xxxx?  In which case, particularly regarding the "artificial
sugar causes cancer", the response should_be really could be more
nicely formatted ("response should be success but was 'redirect' to
'http://'")

Finally, while I'm assuming that I'm doing it properly, is there a
better way to do the response code checking?

Thanks,

Courtenay
http://blog.caboo.se


More information about the rspec-users mailing list