ActionController::TemplateAssertions pollutes @partials, @templates, and @layouts #7459

rehevkor5 opened this Issue Aug 27, 2012 · 1 comment

3 participants


I just tracked a strange problem I was having with my view specs to ActionController::TemplateAssertions. It is using instance variables @partials, @templates, and @layouts on the test itself. I was populating the @templates variable, which is what my view expects to receive. Since TemplateAssertions doesn't expect this, it fails with a "can't convert" error.

TemplateAssertion's internal variables should not be mixed into the test itself. Agree/disagree?

Ruby on Rails member

You need some instance variables to track which templates, partials and layouts have been rendered otherwise the assertions wouldn't work, however they should certainly be prefixed with an underscore to help prevent clashes.

@senny senny added a commit to senny/rails that referenced this issue Oct 1, 2012
@senny senny prefix TemplateAssertions ivars (#7459) bb0f4a1
@rafaelfranca rafaelfranca added a commit that referenced this issue Oct 31, 2012
@rafaelfranca rafaelfranca Revert "Merge pull request #7797 from senny/7459_prefix_tempalte_asse…

This reverts commit 2bad605.


Reason: This added a regression related with shoulda-matchers, since it
is expecting the instance variable @layouts


This will introduce back #7459 but this stable release will be backward compatible.
Related with #8068.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment