An Introduction to Mock Objects in Ruby

Submitted by James Mead 2012-06-01 12:26:08 UTC
Source:  http://jamesmead.org/talks/2007-07-09-introduction-to-mock-objects-in-ruby-at-lrug/

Referenced projects

Mocha

Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.

Rubygem mocha

Total Downloads
8080014
Releases
61
Current Version
1.1.0
Released
2014-05-13 00:00:00 UTC
First Release
2006-07-15 23:00:00 UTC

Github freerange/mocha

Watchers
684
Forks
106
Development activity
Less active
Last commit
2015-04-30 00:01:46 UTC

rspec-mocks

RSpec's 'test double' framework, with support for stubbing and mocking

Rubygem rspec-mocks

Total Downloads
27239306
Releases
90
Current Version
3.2.1
Released
2015-02-24 00:00:00 UTC
First Release
2009-09-16 07:00:00 UTC

Github rspec/rspec-mocks

Watchers
547
Forks
196
Development activity
Active
Last commit
2015-05-25 07:54:41 UTC

Flexmock

FlexMock is a extremely simple mock object class compatible with the Test::Unit framework. Although the FlexMock's interface is simple, it is very flexible.

Rubygem flexmock

Total Downloads
454153
Releases
55
Current Version
1.3.3
Released
2014-01-20 00:00:00 UTC
First Release
2005-10-25 04:00:00 UTC
Depends on following gems
Depending Gems
149

Github jimweirich/flexmock

Watchers
77
Forks
14
Development activity
Inactive
Last commit
2014-01-20 22:52:16 UTC
Contributors
6
Issues

RR

RR is a test double framework that features a rich selection of double techniques and a terse syntax.

Rubygem rr

Total Downloads
1056484
Releases
76
Current Version
1.1.2
Released
2013-08-18 00:00:00 UTC
First Release
2007-07-07 07:00:00 UTC
Depends on following gems
Depending Gems
580

Github rr/rr

Watchers
184
Forks
15
Development activity
Inactive
Last commit
2015-03-31 15:30:48 UTC
Contributors
28
Issues

Minitest

minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking. "I had a class with Jim Weirich on testing last week and we were allowed to choose our testing frameworks. Kirk Haines and I were paired up and we cracked open the code for a few test frameworks... I MUST say that minitest is *very* readable / understandable compared to the 'other two' options we looked at. Nicely done and thank you for helping us keep our mental sanity." -- Wayne E. Seguin minitest/unit is a small and incredibly fast unit testing framework. It provides a rich set of assertions to make your tests clean and readable. minitest/spec is a functionally complete spec engine. It hooks onto minitest/unit and seamlessly bridges test assertions over to spec expectations. minitest/benchmark is an awesome way to assert the performance of your algorithms in a repeatable manner. Now you can assert that your newb co-worker doesn't replace your linear algorithm with an exponential one! minitest/mock by Steven Baker, is a beautifully tiny mock (and stub) object framework. minitest/pride shows pride in testing and adds coloring to your test output. I guess it is an example of how to write IO pipes too. :P minitest/unit is meant to have a clean implementation for language implementors that need a minimal set of methods to bootstrap a working test suite. For example, there is no magic involved for test-case discovery. "Again, I can't praise enough the idea of a testing/specing framework that I can actually read in full in one sitting!" -- Piotr Szotkowski Comparing to rspec: rspec is a testing DSL. minitest is ruby. -- Adam Hawkins, "Bow Before MiniTest" minitest doesn't reinvent anything that ruby already provides, like: classes, modules, inheritance, methods. This means you only have to learn ruby to use minitest and all of your regular OO practices like extract-method refactorings still apply.

Rubygem minitest

Total Downloads
22764488
Releases
92
Current Version
5.6.1
Released
2015-04-27 00:00:00 UTC
First Release
2008-10-09 07:00:00 UTC
Depends on following gems
Depending Gems
3720

Github seattlerb/minitest

Watchers
1470
Forks
274
Development activity
Active
Last commit
2015-05-20 00:17:25 UTC
Top contributors
Contributors
2
Issues

test-unit

Test::Unit (test-unit) is unit testing framework for Ruby, based on xUnit principles. These were originally designed by Kent Beck, creator of extreme programming software development methodology, for Smalltalk's SUnit. It allows writing tests, checking results and automated testing in Ruby.

Rubygem test-unit

Total Downloads
2940231
Releases
44
Current Version
3.0.9
Released
2014-12-31 00:00:00 UTC
First Release
2008-03-20 07:00:00 UTC

Github test-unit/test-unit

Watchers
84
Forks
33
Development activity
Less active
Last commit
2015-04-07 12:10:09 UTC
Contributors
25
Issues
×

In order to continue, you must be signed in using your Github account.

If you're signing in using this account for the first time Github will ask for your permission to give access to your public user data to the Ruby Toolbox.

Although the Github Authorization page does not mention it, the request includes read-only access to your verified email address (user:email OAuth scope). This is neccessary so there's a way to notify you about comments, information about your accepted project edits and the like. You can review your notification settings on your account page once you're signed in.