[mocha-developer] Stubbing objects and calling to_json on them errors (circular reference)

James Mead jamesmead44 at gmail.com
Sun Oct 26 15:16:58 EDT 2008

2008/10/20 John Wilger <johnwilger at gmail.com>

> 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!)

Hi John,

Thanks for your message. There isn't currently a way to do this. I'm not
convinced that always returning "self" would be sensible, but I can see the
case for having control over the default return value. I've added a feature
request [1] to track this and I'll have a think about how the API would
work. In the meantime if you have any ideas, please let me know.



More information about the mocha-developer mailing list