[mocha-developer] Stubbing objects and calling to_json on them errors (circular reference)
bkocik at gmail.com
Mon Oct 20 15:10:05 EDT 2008
On 20 Oct, 2008, at 2:01 PM, John Wilger wrote:
> Hi Bill,
> I would suggest not using an actual instance of Something at all.
> You are testing SomethingController, not Something
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.
I think a work-around I can use for now (until we can clean all of
this up) is to stub the to_json method.
More information about the mocha-developer