assert_template against the same partial with different locals #3675

luisobo opened this Issue Nov 18, 2011 · 6 comments


None yet

6 participants

luisobo commented Nov 18, 2011

I have a view like this

<%= render :partial => 'widget', :locals => { :param => "10" } %>
<%= render :partial => 'widget', :locals => { :param => "20" } %>

Then in RSpec I'm doing this:

rendered.should render_template :partial => 'widget', :locals => { :param => "10" }
rendered.should render_template :partial => 'widget', :locals => { :param => "20" }

The first expectation is failing. It says something like expected "10", found "20". It looks like it's only saving the last partial and checking all my expectations against the last one.

The second expectation is passing.

The RSpec matcher render_template uses assert_template so the problem is the same there.

frodsan commented Apr 29, 2012

@luisobo is this still an issue?


@luisobo Can you provide a test application or reproduce the issue with test-unit?


The rspec definition is here.

The rails definition is here.

I'm not familiar enough with how this is supposed to work. :/ I'm trying to make a rails app that demonstrates this now.


I cannot for the life of me figure out how to make an integration test with test-unit.

Anyway, it would seem to me that the issue is here:

This is going to write two values for the same key, which is why you're seeing the second only.

You could fix this by only writing one assertion per test. ;)

senny commented Oct 8, 2012

@steveklabnik is this considered a bug? I could try to write up a patch. I added a failing test case to illustrate the problem.


I think so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment