Parent

Included Modules

FlexMock::Recorder

                                                                  

Translate arbitrary method calls into expectations on the given mock object.

Public Class Methods

new(mock) click to toggle source

Create a method recorder for the mock mock.

    # File lib/flexmock/recorder.rb, line 24
24:     def initialize(mock)
25:       @mock = mock
26:       @strict = false
27:     end

Public Instance Methods

method_missing(sym, *args, &block) click to toggle source

Record an expectation for receiving the method sym with the given arguments.

    # File lib/flexmock/recorder.rb, line 59
59:     def method_missing(sym, *args, &block)
60:       expectation = @mock.should_receive(sym).and_return(&block)
61:       if strict?
62:         args = args.collect { |arg| eq(arg) }
63:         expectation.with(*args).ordered.once
64:       else
65:         expectation.with(*args)
66:       end
67:       expectation
68:     end
should_be_strict(is_strict=true) click to toggle source

Place the record in strict mode. While recording expectations in strict mode, the following will be true.

  • All expectations will be expected in the order they were recorded.

  • All expectations will be expected once.

  • All arguments will be placed in exact match mode, including regular expressions and class objects.

Strict mode is usually used when giving the recorder to a known good algorithm. Strict mode captures the exact sequence of calls and validate that the code under test performs the exact same sequence of calls.

The recorder may exit strict mode via a should_be_strict(false) call. Non-strict expectations may be recorded at that point, or even explicit expectations (using should_receieve) can be specified.

    # File lib/flexmock/recorder.rb, line 48
48:     def should_be_strict(is_strict=true)
49:       @strict = is_strict
50:     end
strict?() click to toggle source

Is the recorder in strict mode?

    # File lib/flexmock/recorder.rb, line 53
53:     def strict?
54:       @strict
55:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.