[mocha-developer] mocking singletons

Justin Perkins justin at spiceworks.com
Tue Aug 21 14:13:06 EDT 2007

On Aug 21, 2007, at 2:38 AM, James Mead wrote:
> This is one of the things Mocha takes care of for you in the  
> context of a
> test method.

That's what I thought but I was getting weird behavior when I ran all  
the tests that led me to believe the mocked method was lingering around.

>   MySingleton.stubs(:instance).returns(m)

That was it. As soon as I used stubs instead of expects, everything  
works fine. I believe that when you use expects on a singleton, the  
mock lingers after the test is complete.


More information about the mocha-developer mailing list