[mocha-developer] sharing any_instance stubs with subclasses

James Mead jamesmead44 at gmail.com
Sun Mar 7 12:53:00 EST 2010

Hi Justin,

Thanks for trying to send us a patch. I don't think attachments make
it through on Google Groups. Have you considered forking Mocha on
GitHub [1] and sending me a pull request? Alternatively you could use
Gist [2] or Pastie [3] to show us the code.

I have to confess, I haven't used Mocha's any_instance functionality
for a long time. I find there are usually simpler ways of stubbing
methods and setting expectations. Well done for finding that old
mailing list thread. There's another more recent one here [4].

Have you tried running the Mocha tests with your patch applied? Also
it would be really helpful if you could write new acceptance tests
like these [5] to describe the behaviour you are expecting and/or
identify existing tests which describe behaviour you are not

If you're interested in working out how you might avoid the use of
any_instance, it might be worth posting some code and explaining what
you're trying to do and we can see if we can come up with an
alternative approach.

Cheers, James.

[1] http://github.com/floehopper/mocha
[2] http://gist.github.com/
[3] http://pastie.org/
[4] http://groups.google.com/group/mocha-developer/browse_thread/thread/99981af7c86dad5e

More information about the mocha-developer mailing list