[mocha-developer] Testing a call to super
jamesmead44 at gmail.com
Thu Jan 31 15:05:44 EST 2008
On 30/01/2008, Tim Connor <timocratic at gmail.com> wrote:
> Did any further discussion ever come of this? I take it is officially
> not supported currently? I just get an odd error when I try it (it
> throws a "0 expected 1 received", no matter what stubbing/expectation
> combo I use), so came looking around on google, and finally the
> Here's my stripped down example: http://pastie.caboo.se/145603 (it
> fails with expects too)
> Use case is the parent class has some complex functionality and you
> just want to isolate and test something in the subclass.
I'm afraid you're right - this behaviour isn't currently supported. Using a
version from trunk (after revision 233 when I added position information to
all evals as suggested by Ola Bini ), you'll get a slightly more useful
error message. Basically both the Parent & Child classes have their own
"any_instance" mock object. When you call Parent.any_instance.stubs(:say),
the expectation is added to the Parent's "any_instance" mock object. However
when the instance of Child calls super, this is intercepted by the Child's
"any_instance" mock object which has no expectations.
I'm sorry to say, making this work isn't going to be a priority for me, but
I'd be more than happy to consider a patch ;-)
Thanks for your interest.
More information about the mocha-developer