[mocha-developer] Testing a call to super

Tim Connor timocratic at gmail.com
Thu Jan 31 15:15:20 EST 2008


heh, yeah, I figured it would be painful to do.  I just manually
aliased, redefed, and then aliased back after the test.  Ugly, but it
worked.  My primary concern/confusion was the weird error.  Glad to
here it throws something more explicit, now.

Maybe I'll play with it when I really need to work on my ruby-fu some
more.  I bet it's the sort of problem that would really sharpen ones
ax. ;)

Tim

On Jan 31, 2008 12:05 PM, James Mead <jamesmead44 at gmail.com> wrote:
>
> 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
> > mailinglist.
> >
> > 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.
>
>
> Hi Tim,
>
> 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 [1]), 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.
> --
> James.
> http://blog.floehopper.org
> http://tumble.floehopper.org
>
> [1]
> http://ola-bini.blogspot.com/2008/01/ruby-antipattern-using-eval-without.html
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>


More information about the mocha-developer mailing list