0

I'm trying to do the labs on TestFirst.org with rspec. I've installed rspec and initilized it in the project directory. But when i "rake" i get this error message:

 Could not find 'rspec' <~> 2) - did find: [rspec-3.0.0]
 C:/Sites/RubyTest/RubyTesting/learn_ruby/rakefile:2:in `<top (required)>´

My versions:

  ruby 1.9.3p545
  rails 4.1.1
  rspec 3.0.2

Seems like I've got the wrong version of rspec or something. My OS is windows 7 btw.

This is the content of rakefile:

     gem 'rspec', '~>2'
     require 'rspec/core/rake_task'

     task :default => :spec

     desc "run tests for this lab"
     RSpec::Core::RakeTask.new do |task|
     lab = Rake.application.original_dir
     task.pattern = "#{lab}/*_spec.rb"
     task.rspec_opts = [ "-I#{lab}", "-I#{lab}/solution", '-f documentation', '-r        ./rspec_config']
     task.verbose = false
     end
4
  • What is the content of rakefile? Is it requiring the right version? Commented Jul 1, 2014 at 15:07
  • Edited and added rakefile. Commented Jul 1, 2014 at 17:15
  • 1
    Change it to gem 'rspec', '~>3' Commented Jul 2, 2014 at 5:07
  • I have added it as an answer. Please accept if it solved the issue. :) Commented Jul 2, 2014 at 15:45

2 Answers 2

1

This is because rspec ~3.0.0 is already activated and your rake file requires 'rspec', '~>2'. Change rspec version in Rakefile to fix this.

gem 'rspec', '~>3'
Sign up to request clarification or add additional context in comments.

Comments

0

Looks like you have a installed version of rspec (3.0.2) that is more recent than the one expected by the project (~ 2.x).

One simple way to solve it would be to force bundle to use the project version:

bundle exec rake

(instead of just using rake)

1 Comment

Tried this out. But it says: can't activate rspec <~> 2). already activated rspec-3.0.0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.