Read more

Fix warning "already initialized constant Mocha" with Rails 3.2

Henning Koch
February 18, 2013Software engineer at makandra GmbH

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.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

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'
Posted by Henning Koch to makandra dev (2013-02-18 14:49)