In playframework 2.1, is it possible to test an action to make sure the rendered view is the one I'm expecting for?
In ASP.NET MVC 3, AssertViewRendered().ForView("view")
tests exactly that. Can we do it in play 2.1? How?
Very basic MVC 3 example of what I would like to achieve:
// Given the action GetUsers that renders the view "Users", I would like to assert
// this view as the one I expect and no other.
public class UserController
{
public ActionResult Index() {
return View("Users");
}
}
[Test]
public void GetUsersRendersCorrectView()
{
// Setup
var userService = new Mock<UserService>();
var userController = new UserController(userService.Object);
// Excercise
var result = userController.GetUsers();
// Verify
result.AssertViewRendered().ForView("Users");
}
Thanks.