Parent

FlexMock::ExpectationDirector

                                                                  

The expectation director is responsible for routing calls to the correct expectations for a given argument list.

Public Class Methods

new(sym) click to toggle source

Create an ExpectationDirector for a mock object.

    # File lib/flexmock/expectation_director.rb, line 23
23:     def initialize(sym)
24:       @sym = sym
25:       @expectations = []
26:       @defaults = []
27:       @expected_order = nil
28:     end

Public Instance Methods

<<(expectation) click to toggle source

Append an expectation to this director.

    # File lib/flexmock/expectation_director.rb, line 46
46:     def <<(expectation)
47:       @expectations << expectation
48:     end
call(*args) click to toggle source

Invoke the expectations for a given set of arguments.

First, look for an expectation that matches the arguments and is eligible to be called. Failing that, look for a expectation that matches the arguments (at this point it will be ineligible, but at least we will get a good failure message). Finally, check for expectations that don’t have any argument matching criteria.

    # File lib/flexmock/expectation_director.rb, line 38
38:     def call(*args)
39:       exp = find_expectation(*args)
40:       FlexMock.check("no matching handler found for " +
41:         FlexMock.format_args(@sym, args)) { ! exp.nil? }
42:       exp.verify_call(*args)
43:     end

Private Instance Methods

find_expectation_in(expectations, *args) click to toggle source
    # File lib/flexmock/expectation_director.rb, line 81
81:     def find_expectation_in(expectations, *args)
82:       expectations.find { |e| e.match_args(args) && e.eligible? } ||
83:         expectations.find { |e| e.match_args(args) }
84:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.