Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

view.should render_template(:partial => ..., :locals => {...}) does not work as expected. #656

Closed
sujoyg opened this Issue Dec 14, 2012 · 2 comments

Comments

Projects
None yet
2 participants

sujoyg commented Dec 14, 2012

Observed

foo/example.html.haml:

...
render :partial => 'foo/bar'
render :partial => 'foo/baz', :locals => {:var => 10}
...

foo/example.html.haml_spec.rb:

...
it 'should render foo/bar.' do
  render
  # An underscore **must** be used before partial name.
  view.should render_template :partial => 'foo/_bar' 
end

it 'should render foo/baz.' do
  render
  # Underscore must **not** be used before partial name.
  view.should render_template :partial => 'foo/baz', :locals => {:var => 10}  
end
...

Expected

Partial name should be specified in the same way regardless of whether locals are specified in render_template or not.

Owner

dchelimsky commented Dec 14, 2012

@sujoyg thanks for the clear bug report.

render_template is an alias for have_rendered, which redirects control to assert_template, passing the arguments as you write them: https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/matchers/have_rendered.rb#L34-L36.

Would you try the same with assert_template and see if you have the same issue? If so, then the issue is with assert_template and this issue can be closed. If not, please report back the differences you see.

sujoyg commented Dec 14, 2012

The problem is in assert_template in rails 3.2.9.

For those who are interested, I have filed this issue against rails here: rails/rails#8516

@sujoyg sujoyg closed this Dec 14, 2012

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