Sha256: 8c1e2839a76ed2dfbdf02a0df73703f843f6be9cf2f2f9d306ebb90e1b03c0cc

Contents?: true

Size: 1.96 KB

Versions: 47

Compression:

Stored size: 1.96 KB

Contents

= Mocha

Mocha is a library for mocking and stubbing using a syntax like that of JMock[http://www.jmock.org], and SchMock[http://rubyforge.org/projects/schmock]. Most commonly Mocha is used in conjunction with Test::Unit[http://www.ruby-doc.org/core/classes/Test/Unit.html], but it can be used in other contexts.

One of its main advantages is that it allows you to mock and stub methods on _real_ (non-mock) classes and instances. You can for example stub ActiveRecord[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] instance methods like +create+, +save+, +destroy+ and even class methods like +find+ to avoid hitting the database in unit tests.

Mocha provides a unified, simple and readable syntax for both traditional mocking and for mocking with _real_ objects.

Mocha has been harvested from projects at Reevoo[http://www.reevoo.com] by me (James[http://blog.floehopper.org]) and my colleagues Ben[http://www.reevoo.com/blogs/bengriffiths], Chris[http://blog.seagul.co.uk] and Paul[http://po-ru.com]. Mocha is in use on real-world Rails[http://www.rubyonrails.org] projects.

== Download and Installation

Install the gem with the following command...

  $ gem install mocha
 
Or install the Rails[http://www.rubyonrails.org] plugin...

  $ script/plugin install svn://rubyforge.org/var/svn/mocha/trunk

Or download Mocha from here - http://rubyforge.org/projects/mocha

== Examples

* Quick Start - {Usage Examples}[link:examples/misc.html]
* Traditional mocking - {Star Trek Example}[link:examples/mocha.html]
* Setting expectations on real classes - {Order Example}[link:examples/stubba.html]
* More examples on {Floehopper's Blog}[http://blog.floehopper.org]
* {Mailing List Archives}[http://rubyforge.org/pipermail/mocha-developer/]

== License

Copyright Revieworld Ltd. 2006

You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].

Version data entries

47 entries across 47 versions & 3 rubygems

Version Path
redcar-dev-0.12.1dev-java lib/openssl/mocha/README
redcar-dev-0.12.0dev-java lib/openssl/mocha/README
redcar-0.11 lib/openssl/mocha/README
redcar-0.11.0dev lib/openssl/mocha/README
redcar-0.10 lib/openssl/mocha/README
redcar-0.9.2 lib/openssl/mocha/README
redcar-0.9.1 lib/openssl/mocha/README
redcar-0.9.0 lib/openssl/mocha/README
redcar-0.8.1 lib/openssl/mocha/README
redcar-0.8 lib/openssl/mocha/README
redcar-0.7 lib/openssl/mocha/README
redcar-0.6.1 lib/openssl/mocha/README
redcar-0.6 lib/openssl/mocha/README
redcar-0.6.1dev lib/openssl/mocha/README
redcar-0.5.1 lib/openssl/mocha/README
redcar-0.5 lib/openssl/mocha/README
redcar-0.5.6dev lib/openssl/mocha/README
redcar-0.5.5dev lib/openssl/mocha/README
redcar-0.5.4dev lib/openssl/mocha/README
redcar-0.5.3dev lib/openssl/mocha/README