[mocha-developer] Mocking protected/private methods

James Mead jamesmead44 at gmail.com
Tue May 13 11:16:00 EDT 2008

2008/5/10 Tammo Freese <tammo at tammofreese.de>:
>  I have a question concerning mocha's handling
>  of protected and private methods. When expecting
>  such a method, the method is public in the test.
>  I expected the method to keep its original visibilty.
>  Is this intended behaviour, or a bug?

It is a bug. I've had it on my own to-do list for a while, but nobody
has complained about it before, so I haven't prioritised it. It would
be really helpful if you could submit a proper Rubyforge bug report
for it and I'll try and look at it as soon as I can.

As an aside, although Mocha does provide the ability to mock
private/protected methods, it's not usually a good idea, since it
couples your test to the internal implementation of the class under


More information about the mocha-developer mailing list