[mocha-developer] Stubbing objects and calling to_json on them errors (circular reference)
John Wilger
johnwilger at gmail.com
Mon Oct 20 15:46:33 EDT 2008
On Oct 20, 2008, at 12:10 PM, Bill Kocik wrote:
>
> I'm right there with ya, John. Sadly the situation I'm in is that
> I've just joined this project, and it's kind of a mess. In some
> cases I can mock the object (and I do), but in others there are so
> many calls to the object, and then calls to objects that come back
> from those calls, that stubbing all that stuff out is a little bit
> prohibitive. It's in these situations that I opt to create a genuine
> object. Our first step in the cleanup effort is to try to increase
> our test coverage to a level we're comfortable with, so for now I'm
> stuck with writing less-than-ideal tests for less-than-ideal code.
Using `stub_everything` as opposed to just `stub` can alleviate that
to some degree, however the one thing I don't like about Mocha is
`stub_everything` returns nil for all calls. If it instead returned
`self` by default, then it would work better for this kind of
situation. (If anyone knows that there /is/ a way to cause Mocha to
behave this way, please speak up!)
--
Regards,
John Wilger
More information about the mocha-developer
mailing list