still getting this deprecation warning #107

josh-m-sharpe opened this Issue Nov 12, 2012 · 45 comments


None yet

*** Mocha deprecation warning: Change require 'mocha' to require 'mocha/setup'.

I've got:

require "test/unit"
require "mocha/setup" # Should be last

and Gemfile:

gem "mocha", :require => false

..bundled updated, etc...

grep doesn't find "mocha" anywhere else in my project.

@floehopper floehopper was assigned Nov 12, 2012

I'm changing the title of this issue to better match what you're asking about. I hope you don't mind.


I strongly suspect that you have another library in your project that has a dependency on Mocha and is calling require 'mocha'.

I just tried a Ruby project from scratch and I don't see the problem you describe.

Can you post your Gemfile here?


When you used grep to search for "mocha", did that search also search your bundled gems?


If you point your Gemfile at HEAD of mocha master branch like so :-

gem "mocha", git: "git://", require: false

And you set a MOCHA_OPTIONS env var to debug like so :-

MOCHA_OPTIONS=debug bundle exec rake

Then mocha should print a backtrace for any deprecation warnings, which should help determine where the problem lies.

active_support gem has: activesupport-3.2.9/lib/active_support/testing/mochaing.rb

On line 2, it calls require 'mocha'

This is required from ActiveSupport::TestCase

I'm running across this running Rspec.

@onyxraven Rails 3.2.9 is not compatible with mocha 0.13.0. 3.2.10 will be, though.

Seems to work fine for me, save the deprecation warning, which i've just silenced with Mocha::Deprecation.mode = :disabled - but I've got a big note in there to remove that on the next upgrade cycle.


@crankharder - did you get anywhere with your investigations?

hlegius commented Nov 14, 2012

Same problem here :/


@hlegius - have you tried any of the things I suggested to @crankharder ? As I explained in a comment above, when I create a ruby project from scratch and use require 'mocha/setup', I don't see the deprecation warning. So I need you to give me some more information before I can help you.

Just catching up on this..... grepping my gems dir shows more than a few "require 'mocha'"s.


A gem could have a require 'mocha', but if mocha is only named as a development dependency, that require statement ought not to be called. So not all of those gems may be at fault.


@onyxraven @crankharder @hlegius - I'd love to help you, but I need more information. Can you do what I suggested in this comment above? Thanks.

In my case it is other gems that are still requiring mocha incorrectly. As far as I'm concerned this issue is closed.


@crankharder thanks - I'm going to close the issue. If anyone else has some more specifics, feel free to re-open.

@floehopper floehopper closed this Nov 18, 2012

Hey @floehopper - I did what you said, and here's the stack trace. It definitely looks like it's line 2 in the top of active_support/testing/mochaing.rb.

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.

/Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/bundler/gems/mocha-337a72ec916d/lib/mocha.rb:5:in `<top (required)>'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `block in require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:225:in `load_dependency'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/testing/mochaing.rb:2:in `block in <top (required)>'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/core_ext/kernel/reporting.rb:11:in `block in silence_warnings'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/core_ext/kernel/reporting.rb:22:in `with_warnings'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/testing/mochaing.rb:2:in `<top (required)>'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/polyglot-0.3.3/lib/polyglot.rb:63:in `require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `block in require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:225:in `load_dependency'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activesupport-3.1.8/lib/active_support/dependencies.rb:240:in `require'
  /Users/nateberkopec/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/minitest-rails-0.3/lib/minitest/rails/mochaing.rb:2:in `<top (required)>'

Two things I find weird about this:

  1. This particular require 'mocha' is being called inside of silence_warnings. Shouldn't Mocha respect $VERBOSE here and not print the deprecation warning?
  2. Uh, isn't everyone using Mocha in Rails projects getting this warning? That's kind of serious. Is there any workaround or side effects to this? Does mocha still work as intended even if active_support is requiring mocha? I guess I need to roll back a few versions of Mocha for a while?

What version of Rails are you using? This is fixed in Rails 3.2.8 in this pull request and in edge Rails in this pull request.


Actually, looking more closely at the stack-trace, the problem appears to be in minitest-rails, which appears to duplicate code which appears in Rails itself.


Sorry, I'm going mad. The fix to Rails 3-2-stable hasn't yet been released, but it should be in v3.2.10 when it is released.


Although it appears minitest-rails wasn't causing your problem, I have submitted a pull request to fix a similar potential problem. Your problem appears to be because you are using Rails 3.1.8. I think you have a few options, (a) restrict Mocha to a pre 0.13 version in your Gemfile; (b) upgrade to Rails 3.2-stable (or 3.2.10 when it is released); or (c) we can look at back-porting the fix in Rails to 3.1-stable.


@nateberkopec In answer to your specific questions:-

  1. I don't know why require "mocha" is being called within silence_warnings. It's not clear to me that a deprecation warning should respect $VERBOSE. I note that Rails' own deprecation warnings do not respect $VERBOSE. You should be able to use Mocha::Deprecation.mode = :disabled to disable the deprecation warnings anyway.
  2. As I explained above, the problem in Rails is fixed in both the 3-2-stable branch (which will be in the 3.2.10 release) and in the master branch. The fact that a deprecation warning is displayed is not serious. Mocha will still work as intended. The point is to give fair warning that a future release of Mocha will not work as intended if you/ActiveSupport do not change require "mocha" to require "mocha/setup".

Hi, I've just run into this as well with rspec-rails 2.8. 2.12 seems shows only the first warning & no stacktrace.

In spec_helper.rb:

require 'rspec/rails'
require 'rspec/rails/mocha'


gem "rails", "3.1.3"
group :test do
  gem 'rspec-rails-mocha', '~> 0.3.1', :require => false
group :test, :development do
  gem "rspec-rails", "~> 2.8.1"

(Above I believe is exactly per docs at

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.

*** Mocha deprecation warning: `require 'mocha/standalone'` has been deprecated. Please use `require 'mocha/api' instead.

/Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require': cannot load such file -- mocha/object (LoadError)
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/mocking/with_mocha.rb:2:in `<top (required)>'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:315:in `mock_with'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-mocha-0.3.2/lib/rspec/rails/mocha.rb:223:in `block in <top (required)>'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core.rb:93:in `configure'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-rails-mocha-0.3.2/lib/rspec/rails/mocha.rb:222:in `<top (required)>'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
    from /Users/paulm/Dropbox/badger/badger-api/spec/spec_helper.rb:10:in `<top (required)>'
    from /Users/paulm/Dropbox/badger/badger-api/spec/controllers/admin/account_histories_controller_spec.rb:1:in `require'
    from /Users/paulm/Dropbox/badger/badger-api/spec/controllers/admin/account_histories_controller_spec.rb:1:in `<top (required)>'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
    from /Users/paulm/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'

Still getting this as of activesupport-3.2.11.

Solution A:


require 'test/unit' # or similar
require 'mocha/setup'
Mocha::Deprecation.mode = :disabled


require_relative '../config/environment'

Potential downside: forgetting in three months and missing actionable deprecation warnings on the next upgrade.

Solution B:

Rewrite tests to not load config/environment.

Solution C:

Downgrade to Mocha 0.12.7 and wait.


Unfortunately, both recent patch releases (3.2.10 & 3.2.11) of Rails have been security releases and they have not included non-security related changes in the 3-2-stable branch. In case it's useful, as a variation on solution A, I've been using this Rails initializer i.e. config/initializers/mocha.rb:

if Rails.env.test? || Rails.env.development?
  require "mocha/version"
  require "mocha/deprecation"
  if Mocha::VERSION == "0.13.1" && Rails::VERSION::STRING == "3.2.11"
    Mocha::Deprecation.mode = :disabled

This has the merit of only disabling the deprecation warnings for the specific versions of Mocha and Rails which I hope would solve your problem.

Solution C isn't as bad as you might think, because at the moment, there aren't many (if any) fixes or new features in the 0.13.x versions of Mocha that are not in 0.12.7+, so it's not as if you are missing out on anything!

However, please do add a comment on rails/rails#8200 to ask them to release it as soon as possible! Thanks.

Very annoying indeed. Seems like there will not be a new feature/fix release for 3.2.x in the foreseeable future.
Downgraded as suggested and it works. Thank you!

(btw, I am using mocha with rspec)


@the-architect I'm glad that helped. It would be great if you could add a comment on the Rails pull request to say you'd really like it released. Thanks.

The initializer made the deprecation warning disappear for me on Rails 3.2.11 and Mocha 0.13.1, thanks.

markcap commented Feb 15, 2013

I'm getting this deprecation warning in rails 3.1.11. Initializer and using 3-1-stable branch both don't work, and downgrading to 0.12.8 isn't possible as it gives me errors. Any suggestions for this?


Are you using Test::Unit or MiniTest and if so, what version? What version of Ruby are you using? Can you be more specific when you say "Initializer and using 3-1-stable branch both don't work" - what errors are you seeing? What errors do you see when downgrading to 0.12.8?

The 0.12.x series of Mocha was already at 0.12.9 when you posted, have you tried that? And I have just released 0.12.10 which supports MiniTest v4.6.0 and v4.6.1, in case that's what you need.


Also, it looks like Rails v3.1.11 included the changes needed to make it compatible with Mocha v0.13.x. I have seen the tests for a project working with Rails v3.1.11, Mocha v0.13.2 & MiniTest v4.6.0 with no deprecation warning.

rails 3.2.12, mocha 0.13.2, the initializer code didn't work for me, it seems like the initializer is running after the deprecation warnings are printed out (in this instance, I am running rspec directly on my tests, which include test_helper). Thoughts? I'm a rails n00b.

(happens when I run rake test also though...)


@terabyte Have you definitely changed require "mocha" to require "mocha/setup" in test_helper.rb?

What version of Rspec are you using? What version of Ruby are you using? How are you loading Rspec? How are you configuring Rspec to use Mocha? When you say the initializer code "doesn't work", how does this manifest itself? Is there an error or do you mean that the deprecation warning still appears?

If you want to know where the deprecation warning is being generated, try running tests using MOCHA_OPTIONS=debug e.g. MOCHA_OPTIONS=debug rake test. This should give you a stack trace indicating where the offending require statement is being called.

@floehopper I have def. changed all my requires to "mocha/setup". I am using ruby 1.9.2 with RVM, rspec 2.12.0.

Looking at the stack traces, mocha is getting required in my application.rb where it does this:

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)

I had mocha in my "test" group, so I removed "test" from the line above, that still didn't work, but then I tried moving mocha to a different group in my Gemfile and redoing bundle update, and that worked. No idea why my test gem group is getting required directly from that line even after I removed "test" from the %w, but whatevs - it is "fixed" for me for now. Thanks very much for the MOCHA_OPTIONS suggestion, that helped me figure it out!


@terabyte I don't think you should need to change that line in application.rb. Are you using the require: false option for Mocha in the Gemfile? i.e. gem "mocha", require: false? As per the instructions for Mocha with Rails?

markcap commented Feb 19, 2013

The error I was getting in Mocha 0.12.8 was uninitialized constant Mocha::Mockery. However, I just threw the initializer back up there for Mocha 0.13.2 and used the require: false as you said and that seems to have gotten rid of the deprecation warnings! so everything seems to be ok now.

btw, though I wasn't using require: false, when I switched to using it and redid my bundle install, I still got the errors, so I am still using the workaround. Thanks again for commenting!


Just as a heads-up to people involved in this issue, the Mocha deprecation warning should be fixed in Rails as of v3.2.13, v3.1.11 & v3.0.20. So I suggest you upgrade as soon as you can. If you added the Rails initializer that I suggested, don't forget to remove it when you upgrade so that Mocha deprecation warnings are re-enabled. Thanks for your patience.

marcgg commented Mar 19, 2013

@floehopper Updating doesn't seem to fix the deprecation notice

➜  d-rails git:(develop) ✗ bundle show rails
➜  d-rails git:(develop) ✗ bundle show mocha
➜  d-rails git:(develop) ✗ be rspec spec
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.

I can only assume that is due to Rspec or some other library calling require 'mocha'.

What version of Rspec are you using?

Can you try running MOCHA_OPTIONS=debug be rspec spec and supply the stack-trace associated with the Mocha deprecation warning.

marcgg commented Mar 19, 2013

For reference, what happened is that I updated to the latest release of rails and got a crash coming from mocha, so I updated it and got this deprecation notice. After talking to the team it seems that people stopped using mocha 😳. It was setup, but not properly used and no one took the time to remove it from the gemfile so I'll do that which will fix the problem for me.

Just in case other people run into the issue, I'm running rspec 2.11.0 which is pretty old but it doesn't seem to be its fault:

➜  drivy-rails git:(develop) ✗ cd /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-2.11.0
➜  rspec-2.11.0  ag "mocha"
14:examples (`describe` and `it`) but prefer Test::Unit assertions and mocha, rr

I didn't know about the extra option to get debug, that's cool. Running with this:

➜  d-rails git:(develop) ✗ MOCHA_OPTIONS=debug be rspec spec
Loading GemsDetected MiniTest version: 2.5.1
Applying monkey patch for MiniTest gem >= v2.3.0 <= v2.10.1

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.

/Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/mocha-0.13.3/lib/mocha.rb:5:in `<top (required)>'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
  /Users/marcgg/Documents/code/d-rails/config/application.rb:17:in `block in <top (required)>'
  /Users/marcgg/Documents/code/d-rails/config/application.rb:10:in `report'
  /Users/marcgg/Documents/code/d-rails/config/application.rb:16:in `<top (required)>'
  /Users/marcgg/Documents/code/d-rails/config/environment.rb:2:in `require'
  /Users/marcgg/Documents/code/d-rails/config/environment.rb:2:in `<top (required)>'
  /Users/marcgg/Documents/code/d-rails/spec/spec_helper.rb:14:in `require'
  /Users/marcgg/Documents/code/d-rails/spec/spec_helper.rb:14:in `block in <top (required)>'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/spork-0.9.2/lib/spork.rb:24:in `prefork'
  /Users/marcgg/Documents/code/d-rails/spec/spec_helper.rb:6:in `<top (required)>'
  /Users/marcgg/Documents/code/d-rails/spec/controllers/admin/my_nice_controller_spec.rb:1:in `require'
  /Users/marcgg/Documents/code/d-rails/spec/controllers/admin/my_nice_controller_spec.rb:1:in `<top (required)>'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
  /Users/marcgg/.rvm/gems/ruby-1.9.3-p327@d/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'

Hope that helps, but if I'm the only one with the issue, forget about it since we'll be removing mocha.


I think the rspec gem is just a wrapper around a bunch of other gems, so searching in there isn't likely to find much. The require statement is likely to be in the rspec-core gem if my memory serves correctly. Anyway, as you say, it sounds like you don't need to know.

marcgg commented Mar 19, 2013

Oh yeah I forgot about how light the actual rspec gem is! Digging a bit more (in case someone else has the problem) it seems you are right and there are some require mocha in rspec-core. I guess updating rspec would fix this.

➜  rspec-core-2.11.1  ag mocha
  1:require 'mocha/standalone'
  2:require 'mocha/object'
staenker commented Apr 7, 2013

for those using bundler: You need to configure bundler which files to require for a gem if the default require '' is not working. This is the case for mocha. This snipped should help to get rid of the warning by SOLVING the actual problem instead of just disabling just the warning ;)
group :test, :development do
gem 'rspec-rails'
gem 'mocha', :require => 'mocha/api'

@sukima sukima referenced this issue in ryanb/ruby-warrior Aug 24, 2013

Adds a version to Gemfile #74

ciryon commented Dec 22, 2013

If anyone still googles this problem and end up here. I got the same problem, but it was simply that I forgot to use:

gem "mocha", require: false

instead of

gem "mocha"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment