[rspec-users] stub! and stubs

Sam Woodard lists at ruby-forum.com
Mon Oct 12 20:37:55 EDT 2009

I have an interesting setup:  I am using rspec for mocking but I have
mocha installed which give me access to any_instance, expects, etc.  The
problem that I am having is that I want to stub out a method for the
duration of a single example, throughout that example but only for that

If I do,


this is not sufficient because valid is called more than once

If I do,

Goal.any_instance.stubs(:valid?).returns(true) then my tests are not
independent but dependent on one another.

Can anyone help?

Thanks in advance,
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list