okonhq
Last Updated: February 25, 2016
·
439
· jan0sch
2aaae7041aca85da930bcaf14d6768d2

RSpec mocha warning with rails

Since some time you probably noticed ugly deprecation warning made by mocha if using rspec and rails. Usually they look like this:

*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
*** Mocha deprecation warning: Test::Unit or MiniTest must be loaded *before* Mocha.
*** Mocha deprecation warning: If you're integrating with a test library other than Test::Unit or MiniTest, you should use `require 'mocha/api'` instead of `require 'mocha'`.

There are several workarounds for this but there is also a clean solution. ;-) Just modify your Gemfile accordingly:

group :development, :test do
  ...
  gem 'mocha', :require => 'mocha/api'
  ...
end
Say Thanks
Respond