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

David Chelimsky dchelimsky at gmail.com
Sun Jun 13 20:30:09 EDT 2010


On Jun 13, 2010, at 5:32 PM, Kristian Mandrup <kmandrup at gmail.com>  
wrote:

> 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?

view.stub(:_render_partial) before view.should_receive(:_render_partial)


More information about the rspec-users mailing list