Quick Tip: Asserting response redirects in a MonoRail controller test

Reading this post by Sean reminded me of when I first started using the trunk’s BaseControllerTest.  One nifty little property on the base test controller’s mock Response object is RedirectedTo.  So you can do something like this:

   1: // some call on the controller that should do the redirect
   2: Assert.AreEqual("/productSearch/performSearch.rails", Response.RedirectedTo);

In previous MonoRail projects, I used the very nice base class from the guys at Eleutian and it worked great.  But I’ve been using the trunk’s BaseControllerTest exclusively on my current project since it started a few months ago and it rocks as well.  Nice to have it “out of the box” now.

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

This entry was posted in castle, monorail, tdd, web. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

One Response to Quick Tip: Asserting response redirects in a MonoRail controller test

  1. I used this tonight for a future MonoRail validation post. Thank you Joey. Little insights like this are vital for us newbies. We appreciate it.