I am, as usual, assigning an instance variable in a controller's index action 
to find all instances of a model in the database.  I want to write a spec that 
checks that this variable is assigned correctly.  I can do:

it "should provide a collection of widgets in @widgets" do
      widget = Widget.create("title" => "my widget")
      get :index
      assigns[:widgets].should include(widget)
end

or:

it "should provide a collection of widgets in @widgets" do
      widget = Factory.create(:widget)
      get :index
      assigns[:widgets].should include(widget)
end

Is there a better way to do this with a mock model, though?

Thanks,

Brennon Bortz
Software Researcher
Dundalk Institute of Technology
[email protected]
Ph.D. Researcher & Composer - Sonic Arts Research Centre
Queen's University, Belfast
[email protected] / [email protected]

_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to