File: flexmock-0.5.1.rdoc [flexmock-1.3.2 Documentation]

### Home Classes Methods

### 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 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 0.5.0 Released

FlexMock is a flexible mocking library for use in Ruby's Test::Unit test framework. Version 0.5.1 is a minor bug fix release.

## New in 0.5.1

- Version 0.5.1 fixes a problem that caused some older versions of RCov to core dump.

## What is FlexMock?

FlexMock is a flexible Ruby mocking library that works with Ruby's Test::Unit framework to create easy to use mocks.

### Features

- Easy integration with Test::Unit. Mocks created with the flexmock method are automatically verified at the end of the test.

- A fluent interface that allows mock behavior to be specified very easily.

- A "record mode" where an existing implementation can record its interaction with a mock for later validation against a new implementation.

- Easy mocking of individual methods in existing, non-mock objects.

### Example

Suppose you had a Dog object that wagged a tail when it was happy. Something like this:

    class Dog
      def initialize(a_tail)
        @tail = a_tail
      end
      def happy
        @tail.wag
      end
    end

To test the `Dog` class without a real `Tail` object (perhaps because real `Tail` objects activate servos in some robotic equipment), you can do something like this:

require 'test/unit' require 'flexmock'

    class TestDog < Test::Unit::TestCase
      include FlexMock::TestCase

      def test_dog_wags_tail_when_happy
        tail = flexmock("tail")
        tail.should_receive(:wag).once
        dog = Dog.new(tail)
        dog.happy
      end
    end

FlexMock will automatically verify that the mocked tail object received the message `wag` exactly one time. If it doesn't, the test will not pass.

See the FlexMock documentation at onestepback.org/software/flexmock for details on specifying arguments and return values on mocked methods, as well as a simple technique for mocking tail objects when the Dog class creates the tail objects directly.

## Availability

You can make sure you have the latest version with a quick RubyGems command:

    gem install flexmock    (you may need root/admin privileges)

Otherwise, you can get it from the more traditional places:

Download | rubyforge.org/project/showfiles.php?group_id=170

You will find documentation at: onestepback.org/software/flexmock/

-- Jim Weirich

[Validate]

Generated with the Darkfish Rdoc Generator 2.