rubyrspecrubygemsrspec-expectations

"no such file to load -- rspec/expectations (LoadError)"


My Gemfile currently specifies the following:

gem "rspec-expectations", "2.7.0"

When I try to run Cucumber, I get the following:

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

....

The Gemfile I'm working with specifies v 2.7.0, so I tried updating that and re-running Cucumber, and I got the following:

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

....

And obviously, when I uninstall 2.7.0 and just use the latest RSpec version, I get a RubyGem version error.

I found this post and tried updating my version of the rspec-rails gem, but no joy.

I need to work within the constraints of the Gemfile I've been given, so is there any way to fix the initial error (no such file to load -- rspec/expectations (LoadError)) while using version 2.7.0?


Solution

  • Found this article, which talks about the "diff-lcs" gem. OP had two different versions installed, and the newer one was causing a conflict. I checked my Gemlist, discovered I had the right one (v. 1.1.3) and a newer one (v 1.2.5), so I simply uninstalled the newer version and I was able to run my cucumber tests.