Skip to content
This repository has been archived by the owner on Aug 3, 2021. It is now read-only.

Ch 3. rspec and bin/rspec are not always interchangeable #43

Open
JunichiIto opened this issue Dec 29, 2014 · 0 comments
Open

Ch 3. rspec and bin/rspec are not always interchangeable #43

JunichiIto opened this issue Dec 29, 2014 · 0 comments

Comments

@JunichiIto
Copy link

In chapter 3, you wrote "We'll fill in the details in a moment, but if we ran the specs right now from the command line (by typing bin/rspec or just rspec on the command line) the output would be similar to the following:" However bin/rspec and rspec are not always interchangeable. (bin/rspec and bundle exec rspec are usually interchangeable, I think.)

rbenv executes the latest version of RSpec in specific Ruby version. If it differs the one in Gemfile.lock, you may not be able to run tests.

The following scenario shows such case (3.1.7 vs 3.0.0):

➜  cb git:(master) rspec -v
3.0.0
➜  cb git:(master) gem update rspec
Updating installed gems
Updating rspec-core
Fetching: rspec-support-3.1.2.gem (100%)
Successfully installed rspec-support-3.1.2
Fetching: rspec-core-3.1.7.gem (100%)
Successfully installed rspec-core-3.1.7
Updating rspec-expectations
Fetching: rspec-expectations-3.1.2.gem (100%)
Successfully installed rspec-expectations-3.1.2
Updating rspec-mocks
Fetching: rspec-mocks-3.1.3.gem (100%)
Successfully installed rspec-mocks-3.1.3
Updating rspec-rails
Fetching: rspec-rails-3.1.0.gem (100%)
Successfully installed rspec-rails-3.1.0
Updating spring-commands-rspec
Fetching: spring-commands-rspec-1.0.4.gem (100%)
Successfully installed spring-commands-rspec-1.0.4
Gems updated: rspec-core rspec-support rspec-expectations rspec-mocks rspec-rails spring-commands-rspec
➜  cb git:(master) rspec -v
3.1.7
➜  cb git:(master) bin/rspec -v
3.0.0
➜  cb git:(master) bundle exec rspec -v
3.0.0
➜  cb git:(master) rspec
/Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.7.6/lib/bundler/runtime.rb:34:in `block in setup': You have already activated rspec-support 3.1.2, but your Gemfile requires rspec-support 3.0.0. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.7.6/lib/bundler/runtime.rb:19:in `setup'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.7.6/lib/bundler.rb:121:in `setup'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/bundler-1.7.6/lib/bundler/setup.rb:7:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    from /Users/jit/dev/private/cb/config/boot.rb:4:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/dev/private/cb/config/application.rb:1:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/dev/private/cb/config/environment.rb:2:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/dev/private/cb/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/jit/dev/private/cb/spec/features/admin_spec.rb:2:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `block in load_spec_files'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `each'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/configuration.rb:1105:in `load_spec_files'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:96:in `setup'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:84:in `run'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:69:in `run'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/lib/rspec/core/runner.rb:37:in `invoke'
    from /Users/jit/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.7/exe/rspec:4:in `<top (required)>'
    from /Users/jit/.rbenv/versions/2.1.4/bin/rspec:23:in `load'
    from /Users/jit/.rbenv/versions/2.1.4/bin/rspec:23:in `<main>'
➜  cb git:(master) bin/rspec
......

Finished in 0.62278 seconds (files took 0.39209 seconds to load)
6 examples, 0 failures

Randomized with seed 63723

➜  cb git:(master) bin/rspec -v
3.0.0
➜  cb git:(master) be rspec
......

Finished in 0.62967 seconds (files took 2.6 seconds to load)
6 examples, 0 failures

Randomized with seed 49959
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant