我正在将应用程序从rails 3.1更新到3.2并从mongoid 2更新为mongoid 3.当我运行应用程序时,一切运行正常但是当我尝试运行规范时,我得到以下错误(完整stacktrace是这个问题的底部)
/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)
特别是在issue看来,似乎这种错误可能是因为尝试使用mongo驱动程序而不是轻便摩托车引起的。考虑到这一点,我尝试运行mongoid-rspec的规格,以防它是罪魁祸首,但规格都运行良好。所使用的所有内容的确切版本也在下面列出
编辑:
所以我很困惑为什么应用程序在开发中起作用并在我尝试运行测试代码时失败了。我毫不费力地针对开发环境设置运行测试。我看了一下测试和开发环境文件,发现了
config.cache_classes = true
选项造成了所有麻烦。我将其更改为false,我能够运行测试代码
我很高兴能够解决问题的根源,但我希望能够尽可能地了解出现了什么问题。如果有人有他们想要分享的见解,那就太棒了
相关的宝石版本:
完整堆栈跟踪:
/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'