Another Quick Tip: Asserting view renders in a MonoRail controller test
This is another one of those “blog it so I can remember it” posts.
My last post about a similar tip was relating to asserting redirects in a MonoRail controller. This one deals with asserting which view is being rendered in your controller when only RenderView is called.
Controller Code
1: public class CheckoutController : BaseController
2: {
3: public void ValidateOrder(CheckoutOrderDTO orderToValidate)
4: {
5: // code to validate order
6:
7: RenderView("review");
8: }
9: }
Controller Test Code
1: Assert.AreEqual(@"checkoutreview", controller.SelectedViewName);
It’s a subtle difference from asserting redirects, because it doesn’t require the leading “/” or the “.rails” extension to be included.