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

new() click to toggle source

Initialize the recorder.

# File lib/flexmock/expectation.rb, line 483
def initialize
  @expectations = []

Public Instance Methods

apply(mock) click to toggle source

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

# File lib/flexmock/expectation.rb, line 496
def apply(mock)
  obj = mock
  @expectations.each do |sym, args, block|
    obj = obj.send(sym, *args, &block)
method_missing(sym, *args, &block) click to toggle source

Save any incoming messages to be played back later.

# File lib/flexmock/expectation.rb, line 488
def method_missing(sym, *args, &block)
  @expectations << [sym, args, block]