dimanche 9 octobre 2016

Rails 5 after removal of assigns function for controller tests

I used assert_template and assigns extensively before Rails 5 in my controllers tests. For example to test that a link in the view is correct:

assert_select ".left-off-canvas-menu ul li a[href=?]", event_all_items_path(assigns(:event)), "Back to all items"

I figured that assert_template was not difficult to get rid of.

However, I don't know how to replace test cases like the one above.

I know about the gem to include those functions, but I'd like to try without them. So alternatives would be:

Would you make a case to keep the assigns function or would you say it is meant to be hard coded?

Aucun commentaire:

Enregistrer un commentaire