== Hardmock
Strict, ordered mock objects using very lightweight syntax in your tests.
== How
The basic procedure for using Hardmock in your tests is:
* require 'hardmock' (this happens automatically when being used as a Rails plugin)
* Create some mocks
* Setup some expectations
* Execute the target code
* Verification of calls is automatic in =teardown=
The expectations you set when using mocks are strict and ordered.
Expectations you declare by creating and using mocks are all considered together.
* Hardmock::Mock#expects will show you more examples
* Hardmock::SimpleExpectation will teach you more about expectation methods
== Example
create_mocks :garage, :car
# Set some expectations
@garage.expects.open_door
@car.expects.start(:choke)
@car.expects.drive(:reverse, 5.mph)
# Execute the code (this code is usually, obviously, in your class under test)
@garage.open_door
@car.start :choke
@car.drive :reverse, 5.mph
verify_mocks # OPTIONAL, teardown will do this for you
Expects @garage.open_door, @car.start(:choke) and @car.drive(:reverse, 5.mph) to be called in that order, with those specific arguments.
* Violations of expectations, such as mis-ordered calls, calls on wrong objects, or incorrect methods result in Hardmock::ExpectationError
* verify_mocks will raise VerifyError if not all expectations have been met.
== Download and Install
* Homepage: http://hardmock.rubyforge.org
* GEM or TGZ or ZIP: http://rubyforge.org/frs/?group_id=2742
* Rails plugin: script/plugin install
* SVN access: svn co svn://rubyforge.org/var/svn/hardmock/trunk
* Developer SVN access: svn co svn://developername@rubyforge.org/var/svn/hardmock/trunk