1

Doing my first RSpec test and getting an error when I run:

 rspec spec/features/list_movies_spec.rb

error message:

/Users/waymond/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.5.1/lib/bundler/runtime.rb:34:in block in setup': You have already activated rspec-core 2.14.7, but your Gemfile requires rspec-core 2.13.1. Prependingbundle exec` to your command may solve this. (Gem::LoadError)

In my Gemfile.lock, I noticed that there were 2 rspec-core's in there and one was 2.13.0, which might be the problem. Any help on how to go about fixing this is much appreciated. Thank you! Here is my Gemfile:

 source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more:           https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

 group :test, :development do
 gem "rspec-rails", "~> 2.13.1"
 end

 group :test do
 gem "capybara", "2.1.0"
 end

and my Gemfile.lock:

  GEM
  remote: https://rubygems.org/
  specs:
  actionmailer (4.0.2)
  actionpack (= 4.0.2)
  mail (~> 2.5.4)
  actionpack (4.0.2)
  activesupport (= 4.0.2)
  builder (~> 3.1.0)
  erubis (~> 2.7.0)
  rack (~> 1.5.2)
  rack-test (~> 0.6.2)
  activemodel (4.0.2)
  activesupport (= 4.0.2)
  builder (~> 3.1.0)
  activerecord (4.0.2)
  activemodel (= 4.0.2)
  activerecord-deprecated_finders (~> 1.0.2)
  activesupport (= 4.0.2)
  arel (~> 4.0.0)
  activerecord-deprecated_finders (1.0.3)
  activesupport (4.0.2)
  i18n (~> 0.6, >= 0.6.4)
  minitest (~> 4.2)
  multi_json (~> 1.3)
  thread_safe (~> 0.1)
  tzinfo (~> 0.3.37)
  arel (4.0.1)
  atomic (1.1.14)
  builder (3.1.4)
  capybara (2.1.0)
  mime-types (>= 1.16)
  nokogiri (>= 1.3.3)
  rack (>= 1.0.0)
  rack-test (>= 0.5.4)
  xpath (~> 2.0)
  coffee-rails (4.0.1)
  coffee-script (>= 2.2.0)
  railties (>= 4.0.0, < 5.0)
  coffee-script (2.2.0)
  coffee-script-source
  execjs
  coffee-script-source (1.6.3)
  diff-lcs (1.2.5)
  erubis (2.7.0)
  execjs (2.0.2)
  hike (1.2.3)
  i18n (0.6.9)
  jbuilder (1.5.3)
  activesupport (>= 3.0.0)
  multi_json (>= 1.2.0)
  jquery-rails (3.0.4)
  railties (>= 3.0, < 5.0)
  thor (>= 0.14, < 2.0)
  json (1.8.1)
  mail (2.5.4)
  mime-types (~> 1.16)
  treetop (~> 1.4.8)
  mime-types (1.25.1)
  mini_portile (0.5.2)
  minitest (4.7.5)
  multi_json (1.8.2)
  nokogiri (1.6.1)
  mini_portile (~> 0.5.0)
  polyglot (0.3.3)
  rack (1.5.2)
  rack-test (0.6.2)
  rack (>= 1.0)
  rails (4.0.2)
  actionmailer (= 4.0.2)
  actionpack (= 4.0.2)
  activerecord (= 4.0.2)
  activesupport (= 4.0.2)
  bundler (>= 1.3.0, < 2.0)
  railties (= 4.0.2)
  sprockets-rails (~> 2.0.0)
  railties (4.0.2)
  actionpack (= 4.0.2)
  activesupport (= 4.0.2)
  rake (>= 0.8.7)
  thor (>= 0.18.1, < 2.0)
  rake (10.1.1)
  rdoc (3.12.2)
  json (~> 1.4)
  rspec-core (2.13.1)
  rspec-expectations (2.13.0)
  diff-lcs (>= 1.1.3, < 2.0)
  rspec-mocks (2.13.1)
  rspec-rails (2.13.1)
  actionpack (>= 3.0)
  activesupport (>= 3.0)
  railties (>= 3.0)
  rspec-core (~> 2.13.0)
  rspec-expectations (~> 2.13.0)
  rspec-mocks (~> 2.13.0)
  sass (3.2.13)
  sass-rails (4.0.1)
  railties (>= 4.0.0, < 5.0)
  sass (>= 3.1.10)
  sprockets-rails (~> 2.0.0)
  sdoc (0.3.20)
  json (>= 1.1.3)
  rdoc (~> 3.10)
  sprockets (2.10.1)
  hike (~> 1.2)
  multi_json (~> 1.0)
  rack (~> 1.0)
  tilt (~> 1.1, != 1.3.0)
  sprockets-rails (2.0.1)
  actionpack (>= 3.0)
  activesupport (>= 3.0)
  sprockets (~> 2.8)
  sqlite3 (1.3.8)
  thor (0.18.1)
  thread_safe (0.1.3)
  atomic
  tilt (1.4.1)
  treetop (1.4.15)
  polyglot
  polyglot (>= 0.3.1)
  turbolinks (2.1.0)
  coffee-rails
  tzinfo (0.3.38)
  uglifier (2.4.0)
  execjs (>= 0.3.0)
  json (>= 1.8.0)
  xpath (2.0.0)
  nokogiri (~> 1.3)

 PLATFORMS
 ruby

 DEPENDENCIES
 capybara (= 2.1.0)
 coffee-rails (~> 4.0.0)
 jbuilder (~> 1.2)
 jquery-rails
 rails (= 4.0.2)
 rspec-rails (~> 2.13.1)
 sass-rails (~> 4.0.0)
 sdoc
 sqlite3
 turbolinks
 uglifier (>= 1.3.0)

2 Answers 2

3

Run the spec using

$ bundle exec rspec spec/features/list_movies_spec.rb

This will ensure the command is executed with the same version listed in your Gemfile.

It's likely you have more than one rspec versions installed on the system. Using rspec command directly will load the latest, but this conflicts with the version listed in your Gemfile.

Other possible solutions are:

  • uninstall all versions except the one listed in the Gemfile
  • upgrade the rspec version in the Gemfile
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, Simone! Worked right away. I should of thought to update it . Rookie over here lol.
After above command: Could not find gem 'puppet-lint-leading_zero-check (>= 0) ruby' in the gems available on this machine.
0

I solved a similar issue by using a different RVM gemset.

I created a new gemset just for this Rails app and then ran bundle install. Then everything worked properly.

$ rvm gemset create app_name_here
$ rvm gemset use app_name_here
$ bundle install

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.