On 23.1.2008, at 18.57, Corey Haines wrote:

> Nope, that still didn't work.
> Still getting
>     @coupon.stub!(:user=).with(@current_user)
>
> Here's my spec and code using your recommended way:
>
> spec - http://pastie.caboo.se/142451
> code - http://pastie.caboo.se/142452
>
> If I add back
>     @coupon.stub!(:user=).with(@current_user)
>
> they pass.
>
> It seems as though the understanding is that setting up your mock  
> with the options (:user => @current_user) should set stubs for both  
> get and set, but it doesn't. I think it just sets up the stub for  
> the get.

I didn't say it would (and it doesn't and shouldn't):
> You can do it like this:
>
> @coupon = mock_model(Coupon, :user= => nil, :user =>
> @current_user, :save => true)

Note both :user= and :user.

In your pastie you only have :user

Cheers,
//jarkko

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to