The Passionate Craftsman

Ruby, PHP, MySql, Software engineering and more.

Tuesday, 27 July 2010

How to test a redirect with Shoulda

I was trying to test if the controller was redirecting but I was getting a 200 (success) instead of 302. With a standard Unit::Test it was working ok. Then, by printing the response body I so that with Shoulda I was getting a 200 with the text:

So I decided to test if the response was a link (a tag) with redirected as text of the link:

assert_select "a", "redirected"

This is the code showing the same test, one with Unit::Test, the other with Shoulda:

Labels: ,


Post a Comment

Subscribe to Post Comments [Atom]

<< Home