Fix warning "already initialized constant Mocha" with Rails 3.2

You either have an old version of Mocha and an edge version of Rails 3.2, or you have a new version of Mocha and an old version of Rails. The best solution is to update Mocha to the latest version and switch to Rails edge.

If you are using shoulda-matchers or another gem that locks Mocha to an old version, you are out of luck.
More info with many other workarounds that you do not want to use can be found here Show archive.org snapshot . A hack to work around this case is to add the following file to lib/mocha/setup.rb:

require 'mocha'
Henning Koch About 11 years ago