使用rspec执行测试时遇到的麻烦

时间:2013-05-17 08:13:22

标签: ruby-on-rails ruby rspec rspec-rails

每当我运行此命令时

spec spec/controllers/sample_controller_spec.rb

我收到以下错误

/Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:466:in `load_missing_constant': uninitialized constant Spec::Adapters (NameError)
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/activesupport-2.3.18/lib/active_support/dependencies.rb:106:in `rake_original_const_missing'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing_not_from_s3_library'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/rspec-1.3.1/lib/spec/runner/options.rb:314:in `plugin_mock_framework'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/rspec-1.3.1/lib/spec/runner/options.rb:139:in `run_examples'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/rspec-1.3.1/lib/spec/runner/command_line.rb:9:in `run'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/gems/rspec-1.3.1/bin/spec:5
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/bin/spec:19:in `load'
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/bin/spec:19
    from /Users/suman/.rvm/gems/ruby-1.8.7-p357@helpkit3/bin/ruby_noexec_wrapper:14

我的gemfile看起来像这样

group :test do
   gem "rspec", "1.3.1"
   gem "rspec-rails", "1.3.3"
   gem "spork", "~> 0.8.0"
   gem "mocha", "~> 0.13.3"
end

任何人都可以帮我解决这个问题我使用的是rails 2.3.14

1 个答案:

答案 0 :(得分:0)

我整天都在努力解决这个错误,最后当我在gemfile中更改了mocha版本时它起作用了

 gem "mocha", "~> 0.13.3"

gem "mocha", "~> 0.12.8"