[mocha-developer] Mocha Mock's hanging on after test run?

Kevin Clark kevin.clark at gmail.com
Wed Jan 17 18:47:08 EST 2007

Hi James,
Yes, I'd much rather rewrite the tests and code, but as it's the rails
routing code and it's lacking in the test department... ;)

Thanks for the hard work. I really appreciate it. Let me know if
there's some way I can help.


On 1/17/07, James Mead <jamesmead44 at gmail.com> wrote:
> On 17/01/07, Kevin Clark <kevin.clark at gmail.com> wrote:
> >
> > Oh, or re-reading this, if you'd like to push a bugfix it would make
> > my life easy :)
> Hi Kevin,
> I've just had another quick look at this and I think it requires more work
> than I first thought. My suggested fix only clears the expectations - it
> does not return the method to its original implementation.
> The assumption made by Mocha is that any concrete instances on which
> expectations are set will not be re-used between tests. In the example you
> give, state (in the form of the Routes constant which references an instance
> of RouteSet) is being preserved between tests - hence Mocha's assumption is
> broken. It shouldn't be too hard to ensure that Mocha deals with this
> scenario, but I need to get some sleep now. I'll take another look in the
> morning.
> I assume that you're retro-fitting tests to code that you don't want to
> change. Otherwise I'd suggest re-writing the code to be more easily testable
> and avoid retaining state between tests.
> --
> James.
> http://blog.floehopper.org
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer

Kevin Clark

More information about the mocha-developer mailing list