[rspec-users] undefined local variable or method `assigns'

Kristian Mandrup kmandrup at gmail.com
Sun Jun 13 18:32:12 EDT 2010


shared_examples_for "a template that renders the messages/form
partial" do
  it "renders the messages/form partial" do
    view.should_receive(:_render_partial).
      with(hash_including(:partial => "form"))
    render
  end
end

# new.html.erb

<%= render "sidebar", :recent_messages => @recent_messages %>
<%= render "form", :message => @message %>


7) messages/new.html.erb renders the messages/form partial
    Failure/Error: Unable to find matching line from backtrace
    #<ActionView::Base:0x000001014fbc88> received :_render_partial
with unexpected arguments
      expected: (hash_including(:partial=>"form"))
           got:
({:partial=>"sidebar", :locals=>{:recent_messages=>[]}})


So what to do if I call multiple partials from my view?


More information about the rspec-users mailing list