[rspec-users] response.should be_success -- what does this prove?

Matt Wynne matt at mattwynne.net
Fri Jun 5 09:11:11 EDT 2009


On 5 Jun 2009, at 13:36, doug livesey wrote:

> Hi -- if my controller action already ensures that the correct  
> template is being rendered, what use is speccing that it should also  
> be successful?
> I do it, but just because I saw someone else do it ages ago.
> Is there a point?

It checks that the response code indicates to the browser that the  
request was 200 OK (as opposed to, say a 302 redirect, or a 404 not  
found).

It's useful when you're doing TDD as it's the simplest thing to expect  
a controller to do. If you break something it's also quite a nice  
first-failure to have.

see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com



More information about the rspec-users mailing list