[rspec-users] specifying an HTTP status code

Francis Hwang sera at fhwang.net
Sat Dec 1 15:45:16 EST 2007

Hi all,

I'm just starting to work w/ RSpec, so I hope this question isn't too  
obvious or missing the point somehow: Is there a way in RSpec to  
specify that a controller action should use a specific HTTP status  
code? Specifically I want to test for the usage of 301 as opposed to  
302, for a permanent redirection.

response.should be_redirect

looks like it calls ActionController::TestRequest#redirect?, which is  
only testing for a status code from 300..399. In an old-fashioned  
Test::Unit Rails test I could do assert_response, but I can't see  
anything matching that in RSpec. Is there a less-documented feature  
I'm missing?


Francis Hwang

More information about the rspec-users mailing list