由于我怀疑与自动加载有关的事情,我在运行一堆 RSpec 测试时遇到了一些麻烦。这是错误:
/usr/share/ruby-rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:490:in `load_missing_constant': Expected /var/lib/jenkins/.../portfolios/base_manage_controller.rb to define Portfolios::BaseManageController (LoadError)
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:181:in `block in const_missing'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:179:in `each'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.1.4/lib/active_support/dependencies.rb:179:in `const_missing'
from /usr/share/ruby-rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
from /var/lib/jenkins/jobs/.../app/controllers/portfolios/customize_controller.rb:1:in `<top (required)>'
这是文件的标题:
class Portfolios::BaseManageController < ApplicationController
它住在app/controllers/portfolios/base_manage_controller.rb
及其子类:
class Portfolios::CustomizeController < Portfolios::BaseManageController
它住在app/controllers/portfolios/customize_controller.rb
最后这里有一堆自动加载:
config.autoload_paths += Dir["#{config.root}/lib", "#{config.root}/lib/**/"]
config.autoload_paths += %W(#{config.root}/app/models/statistics)
#Any test/dev specific load paths
if not Rails.env.production?
config.autoload_paths += %W(#{config.root}/spec/support)
config.autoload_paths += %W(#{config.root}/spec/support/builders)
config.autoload_paths += %W(#{config.root}/spec/support/modules)
config.autoload_paths += %W(#{config.root}/spec/support/utils)
end
任何帮助将非常感激!