NoMethodError:尝试运行rspec时未定义的方法`active_record'

时间:2012-08-10 08:17:12

标签: ruby-on-rails ruby rspec jruby

使用rspec创建测试工作正常,但如果我想执行这些测试,我会收到以下错误:

NoMethodError: undefined method `active_record' for #<Rails::Application::Configuration:0x3011c001>
    method_missing at org/jruby/RubyBasicObject.java:1687
    method_missing at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/railtie/configuration.rb:85
            (root) at C:/Workspace/OE_11/project_name/config/environments/test.rb:33
       module_eval at org/jruby/RubyModule.java:2277
         configure at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/railtie/configurable.rb:24
            (root) at C:/Workspace/OE_11/project_name/config/environments/test.rb:1
           require at org/jruby/RubyKernel.java:1042
           require at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251
   load_dependency at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:236
           require at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/activesupport-3.2.7/lib/active_support/dependencies.rb:251
            Engine at C:/Workspace/OE_11/project_name/config/environments/test.rb:571
     instance_exec at org/jruby/RubyBasicObject.java:1757
               run at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/initializable.rb:30
  run_initializers at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/initializable.rb:55
              each at org/jruby/RubyArray.java:1615
  run_initializers at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/initializable.rb:54
       initialize! at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/application.rb:136
          __send__ at org/jruby/RubyBasicObject.java:1698
              send at org/jruby/RubyKernel.java:2097
    method_missing at c:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/railties-3.2.7/lib/rails/railtie/configurable.rb:30

...

1 个答案:

答案 0 :(得分:0)

找到我的答案here。我没有在我的项目中使用活动记录。