Comparing Ruby Mock Object Libraries
Continuing on the theme of comparing similar things that I started last week, this week I’ll be taking on Mock Object libraries.
The purpose of a mock object library is to allow you to create “fake” objects that can take the place of the regular objects in your application during testing (you’ll sometimes see them called “test doubles”, by analogy with a stunt double, another kind of stand-in).
There are a several reasons why you might want to use a test double in your tests, the two most common are probably these:
- To take the place of a hard to create or expensive to access object or method call, such as a web services call. Using the test double lets the test system pretend that the expensive object is there, but at a much lower time cost.
- To isolate an object being tested from the details of the rest of the system. In Rails, for example, a controller test might create test doubles for methods in the model so that the controller test can pass or fail separately from whether the model implementation is correct.
Ruby’s open object model and duck-typing makes creating test double objects relatively easy compared to stricter languages like Java. There are four major mock objects packages in Ruby:
- FlexMock is the original Ruby mock object package
- Mocha is quasi-official in that the Rails team uses it for their tests.
- RSpec defines its own mock package
- RRis the newest entry, with shorter syntax and a couple of new features
Here’s a tour of what each package looks like, and when you might use each feature.


After a long time of searching for the right data visualization framework for Flash Platform, some time ago I’ve put my money on
I have been a full-time Ruby programmer for about a year now. I used ruby/rails before then but I didn’t really “get it”. Considering that I was a Java/J2EE guy before and never worked with dynamic languages, it wasn’t surprising. Now that it has been a transformation and a worthy evolution, it is about time to review what makes ruby development fun. Yes, Ruby is known for its dynamism, expressiveness, malleability. But today I hope to list a few tools, techniques, concepts that make my programming experience fun these days. Here they are:
Apple recently released a beta version of its
