Class: FlexMock::Recorder

### Home Classes Methods

### In Files

- lib/flexmock/recorder.rb

### Parent

Object

### Methods

- ::new
- #method_missing
- #should_be_strict
- #strict?

### Included Modules

- FlexMock::ArgumentTypes

### Files

- CHANGES
- GoogleExample.rdoc
- rspec_examples_spec.rdoc
- test_unit_examples_test.rdoc
- index.rdoc
- flexmock-0.4.0.rdoc
- flexmock-0.4.1.rdoc
- flexmock-0.4.2.rdoc
- flexmock-0.4.3.rdoc
- flexmock-0.5.0.rdoc
- flexmock-0.5.1.rdoc
- flexmock-0.6.0.rdoc
- flexmock-0.6.1.rdoc
- flexmock-0.6.2.rdoc
- flexmock-0.6.3.rdoc
- flexmock-0.6.4.rdoc
- flexmock-0.7.0.rdoc
- flexmock-0.7.1.rdoc
- flexmock-0.8.0.rdoc
- flexmock-0.8.2.rdoc
- flexmock-0.8.3.rdoc
- flexmock-0.8.4.rdoc
- flexmock-0.8.5.rdoc
- flexmock-0.9.0.rdoc
- flexmock-1.0.0.rdoc
- flexmock-1.0.3.rdoc
- flexmock-1.0.4.rdoc
- flexmock-1.1.0.rdoc
- flexmock-1.2.0.rdoc
- flexmock-1.3.0.rdoc
- flexmock-1.3.1.rdoc

### Class/Module Index

Quicksearch

- FlexMock
- FlexMock::AnyMatcher
- FlexMock::ArgumentMatching
- FlexMock::ArgumentTypes
- FlexMock::AtLeastCountValidator
- FlexMock::AtMostCountValidator
- FlexMock::CompositeExpectation
- FlexMock::CountValidator
- FlexMock::DefaultFrameworkAdapter
- FlexMock::DefaultFrameworkAdapter::AssertionFailedError
- FlexMock::DuckMatcher
- FlexMock::EqualMatcher
- FlexMock::ExactCountValidator
- FlexMock::Expectation
- FlexMock::ExpectationDirector
- FlexMock::ExpectationRecorder
- FlexMock::ExplicitNeeded
- FlexMock::GenericTestCase
- FlexMock::HashMatcher
- FlexMock::MockContainer
- FlexMock::MockContainerHelper
- FlexMock::MockError
- FlexMock::OptionalProcMatcher
- FlexMock::Ordering
- FlexMock::PartialMockProxy
- FlexMock::ProcMatcher
- FlexMock::RSpecFrameworkAdapter
- FlexMock::RSpecFrameworkAdapter::AssertionFailedError
- FlexMock::RSpecMatchers
- FlexMock::RSpecMatchers::HaveReceived
- FlexMock::Recorder
- FlexMock::SpyDescribers
- FlexMock::TestCase
- FlexMock::TestUnitAssertions
- FlexMock::TestUnitFrameworkAdapter
- FlexMock::Undefined
- FlexMock::UsageError
- FlexMock::UseContainer
- FlexMock::Version
- MiniTest
- MiniTest::Unit
- MiniTest::Unit::TestCase
- Test
- Test::Unit
- Test::Unit::TestCase
- Class
- Module
- Object
- Symbol

No matching classes.

# 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
    def initialize(mock)
      @mock = mock
      @strict = false
    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
    def method_missing(sym, *args, &block)
      location = caller.first
      expectation = @mock.flexmock_define_expectation(location, sym).and_return(&block)
      if strict?
        args = args.collect { |arg| eq(arg) }
        expectation.with(*args).ordered.once
      else
        expectation.with(*args)
      end
      expectation
    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
    def should_be_strict(is_strict=true)
      @strict = is_strict
    end

strict?() click to toggle source

Is the recorder in strict mode?

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.