我的 Gemfile 当前指定以下内容:
gem "rspec-expectations", "2.7.0"
当我尝试运行 Cucumber 时,我得到以下信息:
no such file to load -- rspec/expectations (LoadError)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Library/Ruby/Gems/1.8/gems/rspec-2.7.0/lib/rspec.rb:2
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
/Users/rthomas/dev/companyname/ci/behavior_testing/features/support/env.rb:4
....
我正在使用的 Gemfile 指定 v 2.7.0,所以我尝试更新它并重新运行 Cucumber,得到以下结果:
can't activate rspec-expectations (~> 2.7.0, runtime) for ["rspec-2.7.0"], already activated rspec-expectations-2.14.5 for [] (Gem::LoadError)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:230:in `activate'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:246:in `activate'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:245:in `each'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:245:in `activate'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:35:in `require'
/Users/rthomas/dev/companyname/ci/behavior_testing/features/support/env.rb:4
....
显然,当我卸载 2.7.0 并只使用最新的 RSpec 版本时,我会收到 RubyGem 版本错误。
我找到了这篇文章并尝试更新我的 rspec-rails gem 版本,但没有任何乐趣。
我需要在给定的 Gemfile 的约束范围内工作,那么在使用 2.7.0 版时有什么方法可以修复初始错误(没有要加载的此类文件——rspec/expectations (LoadError))?