Question

I have a spec for a class which uses a stubbed collaborator. Now in my class (let's say class A), I do some manipulation on the collaborator class name (let's say class B) to transform it's own class name into something useful for the class. Problem is: the stubbed collaborator "class B" in the spec is not the real class, but a prophecy object. I'm not in control of the object i'm mocking because it's in a third party library, and I can't provide a getName() or getSignature from it.

Is there a way to extract the original class being doubled in a prophecy object?

Was it helpful?

Solution

Yes, you can

Instead of passing the actauly Collaborator (the prophecy object), call getWrappedObject() on your collaborator, and pass the result of that. getWrappedObject() will return the original object that is wrapped by the collaborator.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top