Posted over 7 years ago. Visible to the public.

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

Owner of this card:

Last edit:
over 7 years ago
Posted by jan0sch to jan0sch's deck
This website uses short-lived cookies to improve usability.
Accept or learn more