Ban use of assigns and render_template (assert_template) in RSpec
The
From https://www.bigbinary.com/blog/changes-to-test-controllers-in-rails-5:
According to Rails team, controller tests should be more concerned about what is the result of that controller action like what cookies are set, or what HTTP code is set rather than testing of the internals of the controller. So, these methods are removed from the core.
Implementation guide
- Create a
🆕 👮 Rails/ControllerTestingorRSpec/RailsControllerTesting(or a better name!) - Make this
👮 flag the use ofassignsandrender_templateinspec/controllersandspec/requests - Suggest to assert on controller result (response body) instead
- Add specs
- Link to https://www.bigbinary.com/blog/changes-to-test-controllers-in-rails-5#reasons-for-removing-assigns-and-assert-template (optional)
- Mention the alternatives to
assignsandrender_templatein, for example, https://docs.gitlab.com/ee/development/testing_guide/testing_levels.html#about-controller-tests (optional)
Contact person
Edited by Peter Leitzen