0

在我将我的 shoulda gem 升级到 3.4.0 后,我的测试将不再运行。

语境:

  • 红宝石 1.9.3-p392
  • 导轨 3.2.12
  • Rspec 2.13.0 Mac
  • OS X 10.8.3

当我设置我的 Gemfile 并运行时,bundle exec rspec spec我收到以下错误:

#Gemfile #1
group :test do
  gem 'rspec-rails', '2.13.0'
  gem 'shoulda', '3.4.0'
end

错误:gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- rspec (LoadError)

#Gemfile #2
group :test do
  gem 'factory_girl_rails', '4.2.1'
  gem 'rspec-rails', '2.13.0'
  gem 'shoulda-matchers', '1.5.0'
end

错误:gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- rspec (LoadError)

#Gemfile #3 
group :test do
  gem 'factory_girl_rails', '4.2.1' 
  gem 'rspec', '2.13.0'
  gem 'shoulda', '3.4.0'
end

错误:/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- rspec/rails (LoadError)

这些是唯一有效的 Gemfile 版本,但它们似乎不是正确的设置:

#Gemfile #4
group :test do
  gem 'factory_girl_rails', '4.2.1'
  gem 'rspec', '2.13.0'
  gem 'rspec-rails', '2.13.0'
  gem 'shoulda-matchers', '1.5.0'
end

#Gemfile #5
group :test do
  gem 'factory_girl_rails', '4.2.1'
  gem 'rspec', '2.13.0'
  gem 'rspec-rails', '2.13.0'
  gem 'shoulda', '3.4.0'
end

完整错误跟踪示例(典型):

/Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- rspec (LoadError)
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/shoulda-matchers-1.5.0/lib/shoulda/matchers/integrations/rspec.rb:2:in `<top (required)>'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/shoulda-matchers-1.5.0/lib/shoulda/matchers.rb:5:in `<top (required)>'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/shoulda-matchers-1.5.0/lib/shoulda-matchers.rb:1:in `<top (required)>'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/bundler-1.3.4/lib/bundler.rb:132:in `require'
    from /Users/wrburgess/dev/jbrb/league-server/config/application.rb:8:in `<top (required)>'
    from /Users/wrburgess/dev/jbrb/league-server/config/environment.rb:2:in `require'
    from /Users/wrburgess/dev/jbrb/league-server/config/environment.rb:2:in `<top (required)>'
    from /Users/wrburgess/dev/jbrb/league-server/spec/spec_helper.rb:3:in `require'
    from /Users/wrburgess/dev/jbrb/league-server/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/wrburgess/dev/jbrb/league-server/spec/config/initializers/app_settings_spec.rb:1:in `require_relative'
    from /Users/wrburgess/dev/jbrb/league-server/spec/config/initializers/app_settings_spec.rb:1:in `<top (required)>'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `block in load_spec_files'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `each'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/configuration.rb:819:in `load_spec_files'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
    from /Users/wrburgess/.rvm/gems/ruby-1.9.3-p392@league/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
4

1 回答 1

1

将 shoulda-matchers 升级到 1.5.4 并将 gem 组更改为开发和测试

从 1.5.X 到 1.5.4 有一个回归。我遇到了同样的问题。

于 2013-03-23T23:09:04.870 回答