[mocha-developer] Removing/overriding/unstubbing a stub?

Duncan Beevers duncanbeevers at gmail.com
Thu Sep 13 17:03:08 EDT 2007


I think in most cases needing to unstub a method is an indication of
over-reaching setup methods and too-aggressive initial stubbing.

There are some instances however, where I'd like to unstub a method
before teardown.  For an example of such a case (good old Time.now)
and a potential approach, see this thread
http://rubyforge.org/pipermail/mocha-developer/2007-August/000409.html

On 9/13/07, James Mead <jamesmead44 at gmail.com> wrote:
> Personally I'm not a big fan of the setup method. I agree with Duncan
> that two separate test cases is one way to go. Alternatively you could
> move the stubbing out of the setup method and into invidual test
> methods and only add it to the ones that need it - I think this has
> the benefit of being clearer and more explicit, but it will depend a
> bit on how many test methods need the stubbed method.
>
> There has been an item on the todo list for a long time about being
> able to "unstub" a method (I think it was first raised by Kevin
> Clark), but not many people have asked for it and we (at Reevoo)
> haven't needed it.
>
> --
> James.
> http://blog.floehopper.org
> http://tumble.floehopper.org
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer
>


More information about the mocha-developer mailing list