Notes:
= FlexMock 0.8.5 Released
FlexMock is a flexible mocking library for use in unit testing and
behavior specification in Ruby. Release 0.8.5 is a minor release with
a few bug fixes.
== Bug Fixes in 0.8.5
* Fixed warning about a void context.
* hsh() argument matcher now reports its matching constraints in error
messages.
== What is FlexMock?
FlexMock is a flexible framework for creating mock object for testing. When
running unit tests, it is often desirable to use isolate the objects being
tested from the "real world" by having them interact with simplified test
objects. Sometimes these test objects simply return values when called, other
times they verify that certain methods were called with particular arguments
in a particular order.
FlexMock makes creating these test objects easy.
=== Features
* Easy integration with both Test::Unit and RSpec. Mocks created with the
flexmock method are automatically verified at the end of the test or
example.
* 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.
* Easy mocking of chains of method calls.
* The ability to cause classes to instantiate test instances (instead of real
instances) for the duration of a test.
=== 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/test_unit'
class TestDog < Test::Unit::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 http://flexmock.rubyforge.org 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:: http://rubyforge.org/project/showfiles.php?group_id=170
You will find documentation at: http://flexmock.rubyforge.org.
-- Jim Weirich
Changes:
= Changes for FlexMock
== Version 0.8.5
* Fixed warning about a void context.
* hsh() argument matcher now reports its matching constraints in error
messages.
== Version 0.8.4
* Added support for rails 2.2.x in should_render_view.
== Version 0.8.3
* Fixed a bug where the by_default option was not completely honored
in some edge cases.
== Version 0.8.2
* Added workaround for compatibility issues with RSpec on Rails.
== Version 0.8.1
* Additional fix for Rails 2.0.2
* Added Joe O'Brien's patch to allow view stubbing in Rails 2.0
* Added Evan Phoenix's patch to remove allocate from default
allocators in new_instances (for Rubinius compatibility).
== Version 0.8.0
* Added by_default
* Added undefined behavior
* Mock methods are added to partial mocks only if they are not
previously defined. This should reduce the need for safe mode.
* respond_to? on mocks now accepts multiple arguments. This eases
mocking in rails a little bit.
* Added experimental view mocking for rails.
== Version 0.7.2
* Changed initial model Id to 10000.
* Added test suggested for RSpec Mocks, just to make sure we were good too.
== Version 0.7.1
* Updated install.rb to handle non-root destination directories via
DESTDIR.
* Fixed operator bug introduced in 0.7.0.
== Version 0.7.0
* Added +and_yield+ as an expectation clause.
* Inspect on Mocks now yield a more consise description.
* Global ordering across all mocks in a container is now allowed.
* Added support for Demeter chain mocking.
* Deprecated a number of mock_* methods.
== Version 0.6.4
* Renamed flexmodel(...) to flexmock(:model, ...) because visually
they were too similar.
== Version 0.6.3
* Added flexmodel() for better support of mocking ActiveRecord models.
* Fixed comment for singleton?
* Fixed coverage report for the partial mocking class.
* Fixed bug when partial mock objects reported they respond to a
method but they actually didn't.
* The flexmock() method now _always_ returns a combination domain/mock
object. For partial mocks, this implies that the domain object now
has mock support methods on it (e.g. should_receive).
* Safe mode for partials was introduced for the small number of cases
where mock support methods in the domain object would cause
problems.
* Internally renamed PartialMock to PartialMockProxy.
== Version 0.6.2
* flexmock() with a block now always returns the domain object.
flexmock() without a block returns the mock object. Note that for
normal mocks, the domain and mock objects are the same. For partial
mocks, the mock is separate from the domain object.
* Added +and_raise+ to the list of expection specifications.
== Version 0.6.1
* Fixed bug that prevented mocks from mocking field assignment operators.
* Fixed bug that prevented partial mocks from being ordered.
== Version 0.6.0
* Dropped class interception.
* Refactored into more granular classes.
* Added RSpec integration.
* Added hash expectations to flexmock() and should_expect().
* Integrated partial mocks into the flexmock() methods.
* Allow non-block configuration of new_instances.
== Version 0.5.1
* Changed the name of any_instance to new_instances.
Deprecated any_instance.
* Added ability to stub any class method in new_instances.
* Added RCov task
* Reworked original behavior hooks to use method aliasing rather than method
procs.
* Fixed bug in stubbing File class methods.
== Version 0.5.0
* Added any_instance stubbing to class objects.
== Version 0.4.5
* Fixed version typo in 0.4.4 (internally claimed to be 0.4.3.1)
== Version 0.4.4
* Added block support to flexstub.
== Version 0.4.3
* Fixed bug where non-direct class methods were not properly handled.
== Version 0.4.2
* Fixed bug where multiple stubs of a class method were not
properly restored.
== Version 0.4.1
* Removed include of Test::Unit::Assertions from Expectations.
* Fixed mocking of kernel methods.
== Version 0.4.0
* Added stubbing for mocking methods of existing objects.
* Added multiple return values for the +and_returns+ method.
* Added block initialization to the flexmock method.
== Version 0.3.2
* Fixed bug when mock is used as a replacement class in class
interception.
== Version 0.3.1
* Fixed some warnings regarding uninitialized variables.
* Added (very) simple class interception.
* Added the mock_factory method to go along with class interception.
* When using Test::Unit integration, avoid mock verification if the
test has already failed for some reason.
== Version 0.3.0
* Added Test::Unit integration.
== Version 0.2.1
* Added strict mode in record mode interface to facility using known
good algorithms for comparison testing.
* Improved the docs and examples. Fixed garbled first example in
README.
== Version 0.2.0
* Added record mode for building expectations.
* Fixed a bunch of documentation.
== Version 0.1.7
* Bumped version because 0.1.6 was uploaded to the wrong Rubyforge area.
== Version 0.1.6
* Added a proc based matcher for arguments (using keyword +on+).
== Version 0.1.5
* Fixed the overzealous argument matching when String is given as an
argument qualifier to +should_receive+.
== Version 0.1.4
* Added eq and any methods for argument matching.
* Added tests for the "first match" argument matching policy.
== Version 0.1.3
* Improved the definition of ordered so that it takes group names
instead of explicit order numbers. This make the code easier to
write and the API easier to understand.
== Version 0.1.2
* Fixed homepage in gem spec.
* Removed autorequire from gemspec.
* Fixed README to be automatically updated with FlexMock Version
== Version 0.1.1
* Added responds_to? and method support.
* Added JMock style expectations.
== Version 0.0.3
* Changed to a GEM package.
== Version 0.0.2
* Updated the documentation.
* Fixed the install script.
== Version 0.0.1
* Initial Version
|