New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`require': no such file to load -- mocha/mini_test (LoadError) #187

Closed
vmcilwain opened this Issue Jan 23, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@vmcilwain
Copy link

vmcilwain commented Jan 23, 2014

I have been trying to understand what I am missing when trying to run my tests using mocha.

I spot checked a few versions
0.9.12
0.12.8
0.13.x
But they all give the same error.

environment:
Rails 3.2.13
Ruby ruby 1.9.2p320

test_helper.rb:
require 'rubygems'
require 'spork'
require 'factory_girl_rails'
require 'simplecov'
require 'ruby-debug'
SimpleCov.start 'rails'
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', FILE)
require 'rails/test_help'
require 'declarative_authorization/maintenance'
require mocha/mini_test

gemfile.rb:
group :test do
gem 'minitest', "> 4.0"
gem 'factory_girl_rails', "
> 4.0", :require => false
gem 'faker', "> 0.9.5"
gem 'shoulda', "
> 2.11.3"
gem 'simplecov', "> 0.4.2"
gem 'mocha', "
> 0.9.12"
gem 'turn', :require => false
gem "spork-testunit", "~> 0.0.8"
end

group :development, :test do
gem 'debugger'
end

error:
/Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': no such file to load -- mocha/mini_test (LoadError)

Any ideas how I can fix this so I can get stubbing to work? I assume it worked at some point since it is being used, but I don't know when it was broken and what broke it.

Edit:
If I don't add the require mocha/mini_test to the bottom of my test_helper.rb file and I run my tests I get the following error:
uninitialized constant MiniTest::Unit::TestCase::SUPPORTS_INFO_SIGNAL

Then all my tests fail regardless.

@floehopper

This comment has been minimized.

Copy link
Member

floehopper commented Jan 23, 2014

I think the problem is that you are looking at the README for v1.0.0.

If you look at the README alongside the relevant version tag, you should see the correct instructions.

I suspect the main thing you need to change is:

# Gemfile
gem 'mocha', '~> 0.12.8', require: false

# test_helper.rb
require 'mocha'

I've added a new issue (#188) to add instructions for older versions to the current README to avoid this kind of confusion.

@vmcilwain

This comment has been minimized.

Copy link

vmcilwain commented Jan 23, 2014

Thanks for the response. I have made the changes to both my gemfile and test helper and have now been presented with the following error:

/Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/expectation_error.rb:2:in <module:Mocha>': superclass mismatch for class ExpectationError (TypeError) from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/expectation_error.rb:1:in<top (required)>'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inblock in require'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/expectation.rb:3:in <top (required)>' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in block in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:inload_dependency'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/mock.rb:2:in<top (required)>'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inblock in require'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/mockery.rb:2:in <top (required)>' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in block in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:inload_dependency'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/api.rb:2:in<top (required)>'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inblock in require'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/integration/mini_test.rb:1:in <top (required)>' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in block in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:inload_dependency'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/integration.rb:45:inblock in <top (required)>'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/integration.rb:44:in each' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha/integration.rb:44:in<top (required)>'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inblock in require'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in load_dependency' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/mocha-0.12.10/lib/mocha.rb:2:in <top (required)>' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:inrequire'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in block in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:inload_dependency'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in require' from /Users/lmcilwain/rails/app/test/test_helper.rb:60:in<top (required)>'
from /Users/lmcilwain/rails/app/test/unit/person_test.rb:1:in require' from /Users/lmcilwain/rails/app/test/unit/person_test.rb:1:in<top (required)>'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb:15:in require' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb:15:inblock in

'
from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb:4:in select' from /Users/lmcilwain/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-10.1.0/lib/rake/rake_test_loader.rb:4:in'

@floehopper

This comment has been minimized.

Copy link
Member

floehopper commented Jan 23, 2014

Sorry. For Rails 3.2.13, try the following:

# Gemfile
gem 'mocha', '~> 0.13.0', require: false

# test_helper.rb
require 'mocha/setup'
@vmcilwain

This comment has been minimized.

Copy link

vmcilwain commented Jan 24, 2014

That looks to be working. Thanks a lot for all your help. I seriously was stuck on this :)

@vmcilwain vmcilwain closed this Jan 24, 2014

@floehopper floehopper self-assigned this Feb 20, 2014

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