[rspec-users] Class mocking

Marcus Roberts M.Roberts at NITTYGRITTY.NET
Fri Feb 27 12:08:18 EST 2009



>Unless RSpec is doing some magic under the hood that I'm not aware of,
>this is expected behavior - you're reassigning the constant value of
>MachineInstance.

>What you really want to do is mock/stub directly on MacineInstance.  e.g.

>MachineInstance.should_receive(:create).and_return @mock_machine

If we did that, would that stub/mock carry over into other spec files run later by autospec, which is what we're seeing.
I can see we're changing the definition of MachineInstance in the spec we do that in, but should that carry over to later specs?

Marcus



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20090227/9a336458/attachment.html>


More information about the rspec-users mailing list