[rspec-users] RSpec 2 view example: render_template

Michael Schuerig michael at schuerig.de
Sun Jun 20 08:30:53 EDT 2010


On http://github.com/rspec/rspec-rails under "View specs" there's an 
example

describe "events/index.html.erb" do
  it "renders _event partial for each event" do
    assign(:events, [stub_model(Event), stub_model(Event)])
    render
    view.should render_template(:partial => "_event", :count => 2)
  end
end

Is this indeed correct? From the outset, it looks wrong because it sets 
an expectation (view.should ...) after the call to render.

Then, no matter if I leave that line where it is or put it before the 
render, I get an exception

undefined method `render_template' for 
#<RSpec::Core::ExampleGroup::Nested_1:0x7f6c0632fea0>


Michael

-- 
Michael Schuerig
mailto:michael at schuerig.de
http://www.schuerig.de/michael/


More information about the rspec-users mailing list