Posted over 6 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:

Copy
*** 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:

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

Owner of this card:

Avatar
jan0sch
Last edit:
over 6 years ago
Posted by jan0sch to jan0sch's deck
This website uses cookies to improve usability and analyze traffic.
Accept or learn more