Mocha is a library for mocking and stubbing using a syntax like that of JMock.
Mocha provides a unified, simple and readable syntax for both traditional mocking and partial mocking.
Download and Installation
Install the gem with the following command…
$ gem install mocha
Or install the Rails plugin…
$ script/plugin install git://github.com/floehopper/mocha.git
Note that versions 0.9.6 & 0.9.7 of the Rails plugin were broken. As of version 0.9.8, you need to explicitly load Mocha after the test framework e.g. by adding “require 'mocha'” at the bottom of test/test_helper.rb.
Or download Mocha…
Quick Start - Usage Examples
Traditional mocking - Star Trek Example
Setting expectations on real classes - Order Example
More examples on James Mead’s Blog
Copyright Revieworld Ltd. 2006