Fix warning "already initialized constant Mocha" with Rails 3.2

Posted . Visible to the public.

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
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2013-02-18 13:49)