Ruby/Rails rspec download errors on run - ruby-on-rails

I get the following error while running
saasbook#saasbook:~/Documents/ruby-calisthenics$ rspec
error message
/home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/formatters.rb:167:in `find_formatter': Formatter 'nested' unknown - maybe you meant 'documentation' or 'progress'?. (ArgumentError)
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/formatters.rb:126:in `add'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:624:in `add_formatter'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:106:in `block in load_formatters_into'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:106:in `each'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:106:in `load_formatters_into'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/configuration_options.rb:24:in `configure'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:96:in `setup'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:85:in `run'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:70:in `run'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:38:in `invoke'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/gems/rspec-core-3.0.3/exe/rspec:4:in `<top (required)>'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/rspec:23:in `load'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/rspec:23:in `<main>'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `eval'
from /home/saasbook/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in `<main>'
I am a newbie to Ruby and Rails. I have been having compatibility issues across the board, any help would be appreciated!
a bit of background of the file directory im trying to run rspec in | it's a file from an online class i am taking. it contains a lib and spec file as required. but the error im getting seems to be an issue with my rspec download.

Edit the .rspec file in the root of your Rails application directory and change the following line from:
--format nested
to:
--format documentation
The nested format no longer exists in rspec-3.0.

Uninstall all previous versions of rspec and its dependencies.
gem uninstall rspec
gem uninstall rspec-core
gem uninstall rspec-mocks
gem uninstall rspec-expectations
Install the correct version of rspec in gem file install rspec.
group :development, :test do
gem 'rspec-rails', '~> 3.0.0'
end
I got this solution from this link

Related

bcrypt LoadError with Rails

I am having trouble finding a solution to this issue, and have tried many fixes others have ran into with no success. I am working on the Ruby on Rails 5 Tutorial by Michael Hartl which requires using bcrypt to implement the has_secure_password feature. When I run the test I get a long error message which starts with:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in 'require': cannot load such file -- bcrypt_ext (LoadError)
I have attempted uninstalling and reinstalling bcrypt with adding --platform=ruby at the end and including various versions in the gemfile; gem 'bcrypt', '~> 3.1.7', 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw], 'bcrypt', '~> 3.1.7', platforms: [:ruby] including various combinations of installing the gem file from the command line. Leaving the gemfile hashed out while installing from the console, uninstalling and running the Bundle Install with just the gemfile link.
This is the entire Error message I am receiving when trying to access the Rails Console:
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in 'require': cannot load such file -- bcrypt_ext (LoadError)
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:16:in `rescue in <top (required)>'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/bcrypt-3.1.11-x64-mingw32/lib/bcrypt.rb:12:in `<top (required)>'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:81:in `block (2 levels) in require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `each'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:76:in `block in require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `each'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler/runtime.rb:65:in `require'
from C:/Ruby23-x64/lib/ruby/site_ruby/2.3.0/bundler.rb:114:in `require'
from C:/Users/Bill/Documents/Sites/sample_app/config/application.rb:7:in `<top (required)>'
from C:/Ruby23x64/lib/ruby/gems/2.3.0/gems/railties-.1.4/lib/rails/command/actions.rb:15:in `require'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/console/console_command.rb:96:in `perform'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in`run'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I am using Ruby version 2.3.3 with Rails version 5.1.4 running on Windows 7x64.
Any insight anyone could offer me at this point would be appreciated.
UPDATE
So after countless hours trying to solve the problem, using the gemfile:
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
was what solved the problem for me. This may not be a permanent solution, but at least it's letting me move forward!
There are more recent solutions you may want to explore, but when I had this problem several months ago with Rails 5.0, I used the accepted answer from this stack overflow question and it worked for me.
Update:
As suggested, I have added full answer in case link becomes dead.
First- Uninstall bcrypt
gem uninstall bcrypt-ruby
Then reinstall
gem install bcrypt --platform=ruby
Then in your Gemfile:
gem 'bcrypt','~>3.1.11' # Or current version

Error compiling Compass LoadError on line ["179"] .. data.rb: Cannot load such file

I've trawled every possible Ruby resource looking for a solution to this error but can't for the life of me figure out what I'm doing wrong.
I'm trying to get my sass compiler working for a Drupal build from a previous project. Using the following stack: Ruby 2.3.0, Sass 3.4.22, Compass & Compass Core 1.0.3, Bundler 1.11.2. I've already tried uninstalling and reinstalling the gems but to no avail.
The error occurs when I run the bundle exec compass watch command, which results in the following output:
LoadError on line ["179"] of /Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/lib/compass/configuration/data.rb: cannot load such file -- breakpoint
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/lib/compass/configuration/data.rb:179:in `require'
/Users/somedude/Sites/devdesktop/taronga-dev/docroot/sites/tarongazoo/themes/custom/taronga/config.rb:9:in `get_binding'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:24:in `eval'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:24:in `parse_string'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:15:in `block in _parse'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:14:in `open'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/serialization.rb:14:in `_parse'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/file_data.rb:7:in `block in new_from_file'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-core-1.0.3/lib/compass/configuration/inheritance.rb:207:in `with_defaults'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/file_data.rb:6:in `new_from_file'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/helpers.rb:19:in `configuration_for'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/configuration/helpers.rb:69:in `add_project_configuration'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:37:in `add_project_configuration'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:25:in `configure!'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/project_base.rb:15:in `initialize'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/commands/update_project.rb:41:in `initialize'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:42:in `new'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:42:in `perform!'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/lib/compass/exec/sub_command_ui.rb:15:in `run!'
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/bin/compass:30:in `block in '
/Users/somedude/.rvm/gems/ruby-2.3.0/gems/compass-1.0.3/bin/compass:44:in `'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/compass:23:in `load'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/compass:23:in `'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/somedude/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `'
Has anyone else encountered something similar when trying to get their SASS compiler to run? ANY help would be much appreciated.
Thanks,
Mark.
Resolved! It was such a simple oversight.
It turns out I just needed to call the missing gems via my Gemfile:
gem 'compass'
gem 'sass'
gem 'sass-globbing'
gem 'breakpoint'
There were also a few version conflicts, but these were resolved by reinstalling gems by specific version, for example:
gem install breakpoint -v 2.5.0
Hopefully this points anyone else having similar issues in the right direction.
Cheers.
Dependencies should automatically be installed, but you could try manually installing the breakpoint gem that it can't find:
gem install breakpoint

circleci continuous integration rails app error require stripe

I am trying to use Circleci for continuous integration and running into an issue. I am deploying a rails 4 app using ruby 2.2.2 and rspec.
When I try to push my first build through circleci I get an error when it tries to run my test suite on the line of code in my 'spec_helper' where I am requiring the stripe gem. I use stripe in the app and test it with 'stripe-mock'
The error is below. So the failure is my line require "stripe" in spec_helper. To be clear rspec runs and passes locally, but I get this error on circleci. I double checked and I have all my environment variables on circleci set up. I've heard that sometimes a gem needs binaries set up on circleci to work. Is this perhaps the problem? How would I do this?
rspec
/home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- stripe (LoadError)
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ubuntu/propel/spec/spec_helper.rb:20:in `block in <top (required)>'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core.rb:97:in `configure'
from /home/ubuntu/propel/spec/spec_helper.rb:18:in `<top (required)>'
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires='
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires='
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/bin/rspec:23:in `load'
from /home/ubuntu/.rvm/gems/ruby-2.2.2#global/bin/rspec:23:in `<main>' rspec returned exit code 1
I should also note that I do have stripe in my gemfile as you can see here:
gem 'stripe'
And you can see where I require stripe in my rspec spec_helper here:
RSpec.configure do |config|
require 'stripe'
require 'stripe_mock'
require 'thin'
Despite having stripe in my gemfile I decided I'd try to add sudo gem install stripe to my circle.yml file to make sure it was included for testing but got the following error:
sudo gem install stripe
ERROR: Error installing stripe:
sudo gem install stripe returned exit code 1
mime-types requires Ruby version >= 1.9.2. Action failed: sudo gem install stripe
And this is even when I specify a ruby version in my circle.yml file as 2.2.2
Instead of adding sudo gem install stripe to your circle.yml file, you should add gem stripe to your Gemfile.
The CircleCI documentation says:
In all likelihood, you'll have a list of libraries and dependencies that your app requires. CircleCI automatically detects Ruby's Gemfile, … and then runs the appropriate commands to install the dependencies.
If you don't already have a Gemfile, you can:
Run gem install bundler.
Create a Gemfile listing the Rubygems your application needs to run, including stripe. It should look something like this:
source "https://rubygems.org"
gem "stripe"
Run the bundle command. This should create a Gemfile.lock file, listing specific versions of the gems you use that are compatible with each other.
Commit bot the Gemfile and Gemfile.lock to your version control system.
The Bundler Web site has a lot more information about Gemfiles.

Rails 3.2.0 rspec debugger not working

I've just upgraded to ruby 1.9.3-p0 and rails 3.2.0. I'm now trying to debug an error in one of my tests using
rspec spec -d
But I get this error:
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:422:in `rescue in debug=': (RuntimeError)
**************************************************
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so: undefined symbol: ruby_threadptr_data_type - /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.so
If you have it installed as a ruby gem, then you need to either require
'rubygems' or configure the RUBYOPT environment variable with the value
'rubygems'.
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug-base19-0.11.25/lib/ruby-debug-base.rb:1:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/ruby-debug19-0.11.6/cli/ruby-debug.rb:5:in `<top (required)>'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:408:in `require'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:408:in `debug='
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:19:in `block in configure'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `each'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `configure'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:21:in `run'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
/home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
**************************************************
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:407:in `debug='
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:19:in `block in configure'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `each'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/configuration_options.rb:18:in `configure'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:21:in `run'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /home/map7/.rvm/gems/ruby-1.9.3-p0#rails3.2/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
Install the new debugger gem that works with Ruby 1.9.3 and 1.9.2:
https://github.com/cldwalker/debugger
Stick this in your Gemfile:
# one-liner to install these properly: bash < <(curl -L https://raw.github.com/gist/1333785)
gem 'linecache19', '0.5.13'
gem 'ruby-debug-base19', '0.11.26'
You'll need to run that one-liner in order for bundler to pick up the proper gems.
EDIT: I forgot to link to the posts I used to get debugging working:
ruby-debug with Ruby 1.9.3?
ruby-debug19 on ruby-1.9.3-preview1
I guess I can't comment on other answers yet, but I found many of these instructions don't mention you'll still need to include the
gem 'ruby-debug19', :require => 'ruby-debug'
line in your Gemfile, in addition to the instructions siannopollo provides. Without this, I get a 'cannot load such file -- ruby-debug' error (OSX, rvm, 1.9.3-p125).
FWIW, the gist is hardcoded to 1.9.3-p0, so if you're on 1.9.3-p125, you might need to edit it (also, generally a bad idea to execute a gist you haven't read).
For me, all it took was:
gem 'debugger'
in the Gemfile
Had to upgrade the following
bundle update ruby-debug-base19

no such file to load -- rspec/matchers - rspec-rails, shoulda, cucumber, factory girl, Rails2.3.10

I've inherited an old Rails2.3 app. It's very complex and has (shock, horror) no tests whatsoever. I'm used to rspec and cucumber so I thought I'd start working on getting specs and features defined for the eventual (long-away) upgrade to Rails 3. It's easier to upgrade if I know exactly what will fail.
Anyway, I found it very difficult to find resources on the internet that show how to set up rspec, cucumber, factory girl, and shoulda in a rails 2.3 environment. My bundle is as follows:
source "http://rubygems.org"
# Production gems
gem "rails", "2.3.10"
gem "nokogiri", "1.4.4"
gem "mysql", "~> 2.8.1"
group :development do
# bundler requires these gems in development
gem 'rspec', '1.3.2'
gem 'rspec-core', '2.5.2'
gem 'rspec-rails', '1.3.4'
end
group :test do
# bundler requires these gems while running tests
gem 'cucumber-rails', '0.4.1'
gem 'factory_girl'
gem 'shoulda', '2.11.3'
gem 'shoulda-matchers'
end
When I go to run
bundle exec rspec spec,
I get the following stacktrace from shoulda:
/Users/sys/src/proj/rails/ruby/1.8/gems/shoulda-2.11.3/lib/shoulda/integrations/rspec2.rb:8: no such file to load -- rspec/matchers (MissingSourceFile)
from /Users/sys/src/proj/vendor/rails/activesupport/lib/active_support/dependencies.rb:184:in `require'
from /Users/sys/src/proj/vendor/rails/activesupport/lib/active_support/dependencies.rb:184:in `require'
from /Users/sys/src/proj/rails/ruby/1.8/gems/shoulda-2.11.3/lib/shoulda.rb:4
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:68:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:66:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:66:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:55:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler/runtime.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.14/lib/bundler.rb:120:in `require'
from /Users/sys/src/proj/config/boot.rb:119:in `load_gems'
from /Users/sys/src/proj/config/../vendor/rails/railties/lib/initializer.rb:164:in `process'
from /Users/sys/src/proj/config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
from /Users/sys/src/proj/config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
from /Users/sys/src/proj/config/environment.rb:12
from /Users/sys/src/proj/spec/spec_helper.rb:4:in `require'
from /Users/sys/src/proj/spec/spec_helper.rb:4
from /Users/sys/src/proj/spec/models/announcement_spec.rb:1:in `require'
from /Users/sys/src/proj/spec/models/announcement_spec.rb:1
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/configuration.rb:386:in `load'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/configuration.rb:386:in `load_spec_files'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/configuration.rb:386:in `map'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/configuration.rb:386:in `load_spec_files'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/command_line.rb:18:in `run'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/runner.rb:55:in `run_in_process'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/runner.rb:46:in `run'
from /Users/sys/src/proj/rails/ruby/1.8/gems/rspec-core-2.5.2/lib/rspec/core/runner.rb:10:in `autorun'
from /Users/sys/src/proj/rails/ruby/1.8/bin/rspec:19
Googling for that error provides frighteningly few hits... I'm not sure what I've done wrong?
Removing rspec-core gives:
bundle exec rspec spec/models/announcement_spec.rb
/Users/sys/.rvm/gems/ree-1.8.7-2011.03#proj/gems/bundler-1.0.14/lib/bundler/rubygems_integration.rb:143:in `gem': rspec-core is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
contents of opt/local/bin/rspec
cat /opt/local/bin/rspec
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'rspec-core' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'rspec-core', version
load Gem.bin_path('rspec-core', 'rspec', version)
I wonder if this is conflicting with other rspec's I have installed (I've a Rails3 app installed, also with bundler/rvm)... Not sure why rspec is being run out of opt/local/bin and not the bundle, though..
I ran into this same problem. After hunting down all binary rspec commands (several locations), I belatedly realized that the 1.3.2 branch of RSPEC titles its binary "spec" and not "rspec".
So the correct commands was always "bundle exec spec spec/models/..." Putting "rspec" meant that bundler failed to find it in my current rvm/gemset and went searching through my entire path, eventually coming up with an /opt/local/bin copy that belonged to an rspec2.x install.
It is possible that an alias allows rspec 1.3.2 to also respond to the "rspec" command, but that was not the case for me. Using "spec" was 100% reliable for avoiding that call for rspec-core and other 2.x modules.
Thanks for the question and all the research above. Charles
It looks like rspec-core, which is from a version of rspec that only supports Rails 3, may be the problem. Try uninstalling that and removing it from your Gemfile.
For comparison, here's a section from our Gemfile that works fine for Rails 2.3:
group :development, :local, :test do
gem "rspec", "= 1.3.1"
gem "rspec-rails", "= 1.3.3"
gem "factory_girl", "= 1.3.3"
gem "webrat", "= 0.7.3"
gem "shoulda", "= 2.11.3"
end
A bundle update rspec-rails fixed this issue for me on rails 3.1.

Resources