[mocha-developer] stubbing in development environment

James Mead jamesmead44 at gmail.com
Thu Nov 23 05:17:31 EST 2006

On 22/11/06, Jason Watkins <jason at jasonwatkins.net> wrote:
> > I think the objections are more practical than philosophical. If you are
> new
> Right. I wasn't interested in this particular debate.

I'm sorry I appear to have touched a nerve. I was merely trying to pass on
advice that I have found useful in my own work.

> Some of these hooks are not considered parts of the published API and so
> are
> > subject to change.
> Right. I've gotten this far on my own. My bringing it up is to

suggest that perhaps it should be part of the API.

As I tried to explain, I think one of the main problems in doing this is
finding somewhere to call the hooks I mentioned in my last email. If you
take the view that you only want to use stubs and have no requirement for
verifying expectations, you still need to decide when to create the
$stubbaglobal variable and when to revert the stubbed objects/classes
to their
original state. Do you have some constructive ideas on this front?

If you feel "you shouldn't do that, so I'm not going to help you do
> it", then another justification would be so that mocha isn't wired so
> directly to Test::Unit.

I think you're being harsh when you say that "I'm not going to help you"
when I gave you the four point explanation below. You should also note that
the HEAD version of Mocha already has a Standalone module which is not wired
directly to Test::Unit, to allow simple integration with other testing

There is nothing to stop you using Mocha in your development environment,
but there are a few issues you should think about...

    1) No convenience methods for creating mocks or stubs - you would have
to directly instantiate them using something like Mocha::Mock.new

    2) $stubba global variable is not defined - you would have to do
something like $stubba = Mocha::Central.new

    3) No auto-verification of expectations - you would have to explicitly
call the verify method on traditional mock/stub objects and
$stubba.verify_all to verify expectations on real objects

    4) Probably most importantly, no rolling back of stubbing - you would
have to explicitly rollback by calling $stubba.unstub_all

Another example would be exploratory programing.

It looks like I'll just write my own.

 Good luck.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mocha-developer/attachments/20061123/6ee881b1/attachment.html 

More information about the mocha-developer mailing list