mercredi 8 juillet 2015

How to write assertion that controller method renders a view for a specific instance?

In an integration test I would like to test whether it renders the show view for a specific instance. To test whether it renders the correct view I can use assert_template 'users/show'. But how can I test not only whether it renders the show view but also that it does so for instance @user1?

I looked here but that only discusses it for partials. And if I use assert_template 'users/show', locals: { id: @user1.id } in my test (which seems to be the set up for partials), the test always passes, so also if I replace user1 with user2. Also assert_template 'users/show(@user1)' does not work.

Aucun commentaire:

Enregistrer un commentaire