[rspec-users] Newbie question

Andy Goundry andy at adveho.net
Tue Dec 4 11:06:23 EST 2007


cheers Tom. That worked. I'll go dig in the rspec source...

On 04/12/2007, Tom Stuart <tom at experthuman.com> wrote:
>
> On 4 Dec 2007, at 15:41, Andy Goundry wrote:
> > I've created the following spec test to simply ensure that the
> > Account model receives a call to :new, but the spec is failing as it
> > also receives a call to :save! and it isn't expecting it. I am using
> > "@account = mock_model(Account)". If i replace this with "@account =
> > mock('account', :null_object => true)" the test passes, but i'm not
> > sure that's really what i want. I'm pretty sure i need to us
> > mock_model in this instance.
>
> mock_model doesn't do anything magic -- it just creates a mock (with a
> conveniently-chosen name) and stubs out a few useful methods for you.
> In your case you need to stub out #save! too, so that you don't get
> the failure: @account = mock_model(Account, :save! => true).
>
> Cheers,
> -Tom
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071204/2e0862a9/attachment.html 


More information about the rspec-users mailing list