2

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?

David Grayson
  • 84,103
  • 24
  • 152
  • 189
D_S_B
  • 208
  • 3
  • 9

2 Answers2

3

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.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
  • Thanks, but I tried that and got the same error again – D_S_B Aug 03 '14 at 18:19
  • Please run `gem list` and add the output of it to your question so we can see what gems you have. Also, what was the output of `bundle` when you ran it? It should have told you what rspec version it installed. – David Grayson Aug 03 '14 at 18:41
  • Output of bundle: `Using rake 10.3.2 Using diff-lcs 1.2.5 Using rspec-support 3.0.3 Using rspec-core 3.0.3 Using rspec-expectations 3.0.3 Using rspec-mocks 3.0.3 Using rspec 3.0.0 Using bundler 1.6.5 Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.` – D_S_B Aug 03 '14 at 18:46
  • Done, and now I get this error: `C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/ core/configuration.rb:1057:in `load': cannot load such file -- c:/Users/DB/Documents/learn_ruby-master/B/Documents/learn_ruby-master/00_hello (LoadError)` – D_S_B Aug 03 '14 at 19:00
  • Well, that's a different error and I consider your original question to be answered. You can search for information about LoadErrors online, basically Ruby can't find thet file so you need to make sure it's there or fix the way you are requiring it. Just look at all the files and figure out why RSpec is looking for that one and fix it. Also, this still looks broken because RSpec 3.0.3 is in your error message when in fact you should be using RSpec 2.x. Uninstall RSpec 3.x like I said in my answer. – David Grayson Aug 03 '14 at 19:28
  • So confusing. I've done this so many time already. I redid the uninstall and reinstall the other version, and now I'm onto this error: `rake aborted! LoadError: cannot load such file -- rspec/core/rake_task c:/Users/DB/Documents/learn_ruby-master/Rakefile:3:in `'` – D_S_B Aug 03 '14 at 19:48
  • Since I helped you get the right version of Rake to be installed, I consider this question to be answered. You could ask a new question regarding this new error but you should really look at the full stack trace and the directory listings and try to figure it out for yourself first. – David Grayson Aug 03 '14 at 21:19
  • That error is intentional, it's part of the course. Read the instructions in the `index.html` file inside the `00_hello` folder. – shender Aug 04 '14 at 08:36
0

You need to change the rspec version in the Rakefile NOT the Gemfile from ,gem 'rspec', '~> 2.0' to whatever version you want to use.