[mocha-developer] mocking singletons
jamesmead44 at gmail.com
Wed Aug 22 05:00:01 EDT 2007
On 21/08/07, Justin Perkins <justin at spiceworks.com> wrote:
> 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.
That sounds wrong. "expects" should work as well. You may have found a bug.
If you get the chance can you try and distill the failing scenario down to
the smallest self-contained test you can and post it too the list.
More information about the mocha-developer