`rescue in depend_on': No such file to load -- mongo when running rspec

404 views Asked by At

I'm in the process of updating an app from rails 3.1 to 3.2 and from mongoid 2 to mongoid 3. When I run the application everything runs fine but when I try to run the specs I get the following error (the full stacktrace is at the bottom of this question)

/Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- mongo (LoadError)

Looking around and at this issue in particular it would seem that this kind of error might be caused by something trying use the mongo driver rather than moped. With this in mind I tried running mongoid-rspec's specs in case it was the culprit but the specs all ran fine. The exact versions of everything being used are list below too

EDIT:

So I was puzzled as to why the the app worked in development and fell over when I tried to run the test code. I ran the tests against the development environment settings without any trouble at all. I had a look at the test and development environment files and discovered that the

config.cache_classes = true

option was causing all the trouble. I changed it to false and I was able to run the test code

I'm happy to have got to the bottom of the problem but I would like to have as good an understanding of what went wrong as possible. If anyone has an insights that they would like to share that would be great

The relevant gem versions:

  • carrierwave (0.9.0)
  • carrierwave-mongoid (0.6.3 2beeb87)
  • factory_girl (2.1.2)
  • factory_girl_rails (1.2.0)
  • mongoid (3.1.6)
  • mongoid-grid_fs (1.3.3)
  • mongoid-rspec (1.9.0)
  • mongoid-tree (1.0.4)
  • moped (1.5.1)
  • rails (3.2.15)
  • rspec (2.14.1)
  • rspec-core (2.14.7)
  • rspec-expectations (2.14.4)
  • rspec-mocks (2.14.4)
  • rspec-rails (2.14.0)

Full stack-trace:

/Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:317:in `rescue in depend_on': No such file to load -- mongo (LoadError)
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:312:in `depend_on'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/activesupport-3.2.15/lib/active_support/dependencies.rb:225:in `require_dependency'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/engine.rb:444:in `block (2 levels) in eager_load!'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/engine.rb:443:in `each'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/engine.rb:443:in `block in eager_load!'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/engine.rb:441:in `each'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/engine.rb:441:in `eager_load!'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/initializable.rb:30:in `run'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/initializable.rb:54:in `each'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/application.rb:136:in `initialize!'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/railties-3.2.15/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/conor/Documents/dev/orig/TreeMetricsWebApp/config/environment.rb:5:in `<top (required)>'
from /Users/conor/Documents/dev/orig/TreeMetricsWebApp/spec/spec_helper.rb:3:in `require'
from /Users/conor/Documents/dev/orig/TreeMetricsWebApp/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/conor/Documents/dev/orig/TreeMetricsWebApp/spec/models/cross_cut_spec.rb:1:in `require'
from /Users/conor/Documents/dev/orig/TreeMetricsWebApp/spec/models/cross_cut_spec.rb:1:in `<top (required)>'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `block in load_spec_files'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `each'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/configuration.rb:896:in `load_spec_files'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:22:in `run'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run'
from /Users/conor/.rvm/gems/ruby-1.9.3-p484@tm_orig/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun'
0

There are 0 answers