Class: FlexMock::Extensions::ActiveRecordModel

### Home Classes Methods

### In Files

- lib/flexmock/extensions/active_record_model.rb

### Parent

Object

### Methods

- #create
- #handle
- #post_create

### 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::CallValidator
- FlexMock::CompositeExpectation
- FlexMock::CountValidator
- FlexMock::DefaultFrameworkAdapter
- FlexMock::DefaultFrameworkAdapter::AssertionFailedError
- FlexMock::DuckMatcher
- FlexMock::EqualMatcher
- FlexMock::ExactCountValidator
- FlexMock::Expectation
- FlexMock::ExpectationBuilder
- FlexMock::ExpectationDirector
- FlexMock::ExpectationRecorder
- FlexMock::ExplicitNeeded
- FlexMock::ExtensionRegistry
- FlexMock::Extensions
- FlexMock::Extensions::ActiveRecordModel
- FlexMock::GenericTestCase
- FlexMock::HashMatcher
- FlexMock::MockBuilder
- FlexMock::MockContainer
- 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::Extensions::ActiveRecordModel

### Public Instance Methods

create(container, opts) click to toggle source

Create the test double.

Create the custome test double according to the data from the argument list. The object returned from this method is the object returned from the original flexmock() method call. This the returned object is NOT the actual mock object (which is the case for things like partial proxies), then the opts.mock field should be set to contain the actual mock object.

    # File lib/flexmock/extensions/active_record_model.rb, line 31
    def create(container, opts)
      id = next_id
      FlexMock.new("#{opts.data[:model_class]}_#{id}", container)
    end

handle(args, opts) click to toggle source

Handle the argument list.

This method is called whenever an unrecognized symbol is detected in the flexmock argument list. If the extension class can handle it, it should return true.

Extension data can be stored in the opts.data hash for later use during the create and post_create phase.

    # File lib/flexmock/extensions/active_record_model.rb, line 15
    def handle(args, opts)
      return false unless args.first == :model
      args.shift
      opts.data[:model_class] = args.shift
      opts.extended = self
      true
    end

post_create(opts, location) click to toggle source

Do any post-creation setup on the mock object.

    # File lib/flexmock/extensions/active_record_model.rb, line 37
    def post_create(opts, location)
      add_model_methods(opts.mock, opts.data[:model_class], location)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.