Details
-
Sub-task
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
1.1-rc-2
-
None
Description
Example from the mailing list
import groovy.mock.interceptor.StubFor class Speaker { String name def startLecture() { "Starting..." } } def speakerStub = new StubFor(Speaker) speakerStub.demand.startLecture() { "Intercepted!" } def speaker1 = new Speaker() speakerStub.use { def speaker2 = new Speaker() assert speaker1.startLecture() == "Starting..." // I would have expected "Intercepted!" here assert speaker2.startLecture() == "Intercepted!" }
Dierk's answer:
MockFor and StubFor work by replacing the MetaClass with a ProxyMetaClass
and therefore should not be dependend on whether you instantiate the
object before or inside the use closure.
If they do, it's a bug (maybe introduced by the latest changes to
the MOP impl). Please raise an issue.
I'm flagging this as a blocker because it is MetaClass related and we're on crunch mode.