[rspec-users] stub with assigns?
Pat Maddox
pergesu at gmail.com
Thu Dec 13 02:12:29 EST 2007
On Dec 12, 2007 11:00 PM, Jonathan Linowes <jonathan at parkerhill.com> 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")
huh? I think what you want to be doing is
Foo.stub!(:find_foo).and_return @mock_foo
and then assigns[:foo] will of course be set to @mock_foo.
Pat
More information about the rspec-users
mailing list