Mocha is a library that helps isolating code when testing. It allows to redefine a method and force it to return an expected value, or add an empty method to a given class. This is mostly useful when we want to test behavior that depends on an expensive method call: if we don't care about the expensive method call, we can just stub it and do our normal testing supposing that the expensive method will return something (which we define a-priori).
Put this in your config/environments/test.rb
config.gem "mocha", :version => '0.9.8'
Then install it:
sudo rake gems:install rake gems:unpack GEM=mocha RAILS_ENV=test
And that's it!.
Documentation and Examples