Bundle exec rspec VS rspec specification

Ruby 1.9.2 Rails 3.1

Here is the bundle exec rspec spec/ does not work, but rspec spec/ works fine.

When I run c:\RailsInstaller\work\apptwit>bundle exec rspec spec/ (this is the directory where my application is located, so the specification path does not need to be specified) I get

 c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `require': no such file to load -- spec_he lper (LoadError) from c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i n `load' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i n `block in load_spec_files' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i n `map' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i n `load_spec_files' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in `run' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_i n_process' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run' from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block in autorun' 

/ spec exists as there is spec_helper.rb in it.

So, I have 2 questions:

  • Why does bundle exec rspec spec/ not work and rspec spec/ not have problems?

  • What is the difference between the two teams?

+4
source share
1 answer

Check out this answer . bundle exec modifies your $PATH or %PATH% in case of Windows. As a result, using bundle exec rspec , you invoke the RSpec version specified in the Gemfile . rspec works without the Bundler, executes the $PATH command.

The error you see may be caused by the fact that the RSpec version in your $PATH not compatible with the version of Rails you are working with. The version installed and running Bundler (with bundle exec rspec ) is compatible and works fine.

+16
source

Source: https://habr.com/ru/post/1383330/


All Articles