On Tue, May 31, 2011 at 2:57 PM, Chris Habgood <chabg...@gmail.com> wrote:
> The program works when I run it on the server. > > describe FoodsController do > render_views > > before(:each) do > Food.delete_all > login_as_admin > Food.stubs(:find).with("1").returns(@food = mock_model(Food, > :save=>false)) > end > > #describe "stub_model(Food) with a hash of stubs" do > #let(:food) do > # stub_model Food, :id => 5, :food =>{:name => 'brisket'} > #end > > In my earlier post, I've already told you not to use mocks for your models. It's more hassle than it is worth. before(:each) do @food = Food.new @food.id = 1 end describe "GET 'edit'" do it "should be successful" do Food.stub(:find).with("1").and_return(@food) get :edit assigns(:food).should == @food end end ^ This should work. > > describe "GET edit" do > it "should assign the requested food to @food" do > #Food.should_receive(:find).with("1").and_return(@food) > puts @food > > get :edit, :id => @food.id > assigns(:food).should be(@food) > end > end > end > On Tue, May 31, 2011 at 13:50, Ken Egervari <ken.egerv...@gmail.com>wrote: > >> >> On Tue, May 31, 2011 at 2:38 PM, Chris Habgood <chabg...@gmail.com>wrote: >> >>> Still getting the same error. ugggh. >> >> >> Truly, you have to give us some more code to help you. >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users@rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > *"In matters of style, swim with the current; in matters of principle, > stand like a rock." > Thomas Jefferson > * > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users