D_S_B D_S_B - 5 months ago 28
Ruby Question

Rake Aborted! Gem::LoadError: Could not find rspec 'x' but did find 'y'

I'm working my way through the test first ruby tutorials (https://github.com/alexch/learn_ruby/blob/master/index.html) and I'm having a problem running my rake tests. This is the error message I have:

"rake aborted!
Gem::LoadError: Could not find 'rspec' (~> 2) - did find: [rspec-3.0.0]"

I assume that this is requiring a previous version of rspec than what I have installed, so I have uninstalled and reinstalled 3 previous versions of rspec, but then I get hit with gem not found errors. I have also completed part of these tutorials on a different computer successfully, but I can't seem to figure out the proper setup for this windows 7 machine. I have tried so many different commands and updates to no avail. I've looked through similar questions asked here, but none of the solutions worked for me either.

The following is the output of

gem list
:

*** LOCAL GEMS ***

actionmailer (3.2.18)
actionpack (4.1.1, 3.2.18)
actionview (4.1.1)
activemodel (3.2.18)
activerecord (3.2.18)
activerecord-sqlserver-adapter (3.2.12)
activeresource (3.2.18)
activesupport (4.1.1, 3.2.18)
arel (3.0.3)
bigdecimal (1.1.0)
builder (3.2.2, 3.0.4)
bundler (1.6.5, 1.6.2)
coffee-rails (4.0.1)
coffee-script (2.2.0)
coffee-script-source (1.7.0)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.0.2)
hike (1.2.3)
i18n (0.6.9)
io-console (0.3)
journey (1.0.4)
jquery-rails (3.1.0)
json (1.8.1, 1.5.5)
mail (2.5.4)
mime-types (1.25.1)
minitest (5.3.3, 2.5.1)
multi_json (1.10.0)
pg (0.17.1 x86-mingw32)
polyglot (0.3.4)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-ssl (1.3.4)
rack-test (0.6.2)
rails (3.2.18)
railties (4.1.1, 3.2.18)
rake (10.3.2, 10.3.1, 0.9.2.2)
rb-readline (0.5.1)
rdoc (3.9.5)
rspec (3.0.0)
rspec-core (3.0.3)
rspec-expectations (3.0.3)
rspec-mocks (3.0.3)
rspec-support (3.0.3)
rubygems-update (2.4.1)
rubyzip (1.1.3)
sass (3.2.19)
sass-rails (4.0.3)
sprockets (2.11.0, 2.2.2)
sprockets-rails (2.1.3)
sqlite3 (1.3.9 x86-mingw32)
sqlite3-ruby (1.3.3)
thor (0.19.1)
thread_safe (0.3.3)
tilt (1.4.1)
tiny_tds (0.6.1 x86-mingw32)
treetop (1.4.15)
tzinfo (1.1.0, 0.3.39)


Can anyone please help?

Answer

That tutorial has a Gemfile that specifies that it needs rspec ">= 2.0" which probably excludes rspec 3. To install the proper versions of all needed gems, try these commands in the same folder as the Gemfile:

gem install bundler
bundle

EDIT: Actually, I think that tutorial's Gemfile is broken and didn't properly specify what version of rspec they wanted to use. They should have something like "~> 2.0" instead of ">= 2.0" I think. Try uninstalling rspec with gem uninstall rspec and then do gem install rspec -v 2.14.1. You could open a github issue asking them to update the tutorial to account for the new RSpec 3.x, which is not compatible with 2.x.

Comments