class FlexMock::ExpectationRecorder
An expectation recorder records any expectations received and plays them back on demand. This is used to collect the expectations in the blockless version of the new_instances call.
Public Class Methods
Source
# File lib/flexmock/expectation_recorder.rb, line 21 def initialize @expectations = [] end
Initialize the recorder.
Public Instance Methods
Source
# File lib/flexmock/expectation_recorder.rb, line 34 def apply(mock) obj = mock @expectations.each do |sym, args, kw, block| obj = obj.send(sym, *args, **kw, &block) end end
Apply the recorded messages to the given object in a chaining fashion (i.e. the result of the previous call is used as the target of the next call).
Source
# File lib/flexmock/expectation_recorder.rb, line 26 def method_missing(sym, *args, **kw, &block) @expectations << [sym, args, kw, block] self end
Save any incoming messages to be played back later.