Sha256: 10546b102ed08f29b71099cbd34293566016b12d117188f4f790a12450333d99

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

== 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'
* 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 <b>strict</b> and <b>ordered</b>.
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 <tt>@garage.open_door</tt>, <tt>@car.start(:choke)</tt> and <tt>@car.drive(:reverse, 5.mph)</tt> 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
* <tt>verify_mocks</tt> 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

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
minilab-1.0.0-mswin32 vendor/hardmock/README
hardmock-1.1.0 README
hardmock-1.2.0 README