>> Sorry, perhaps I gave too simplistic an example. >> Real code, please? :-)
Simplified examples only ever result in simplistic suggestions. Daniel On 13 Dec 2007, at 07:55 13 Dec 2007, Jonathan Linowes wrote: > > On Dec 13, 2007, at 2:47 AM, Jonathan Linowes wrote: > >> >> On Dec 13, 2007, at 2:06 AM, Jarkko Laine wrote: >> >>> >>> On 13.12.2007, at 9.00, Jonathan Linowes wrote: >>> >>>> is there a way to stub a method that sets an instance variable, so >>>> the stub sets it too? >>>> >>>> def find_foo >>>> @foo = Foo.find(params[:id] >>>> end >>>> >>>> >>>> ... >>>> controller.stub!(:find_foo).and_assigns(:foo, "123") >>> >>> Why don't you just stub Foo.find? That way the instance var gets >>> assigned automatically. >>> >>> //jarkko >>> >> >> Sorry, perhaps I gave too simplistic an example. >> My question is what if I want to stub the whole find_foo method >> but one of its side effects is it sets @foo >> (rather than stub the internals of find_foo) >> >> > ... and @foo is used by the method that i am testing > > _______________________________________________ > 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