Please sign in to comment.
Use Rails-recommended binstub for RSpec
Some Ruby gems provide an executable to run its contained Ruby program. We most commonly use `rails`, `rspec`, and `rake`. When we type `rspec` within the root of our project, Rubygems will use the latest version of the RSpec gem, not the version specified in the project's `Gemfile`. That's a problem that Bundler's `bundle exec` solves. It's tedious to type `bundle exec`, however. We previously solved that problem via a directory convention for Bundler's binstubs and adding that directory to our shell's `PATH`. Running `bundle binstub rspec` generates a binstub file in the `bin` directory. Running `./bin/rspec` is now the same thing as running `bundle exec rspec`. Adding `export PATH=".git/safe/../../bin:$PATH"` and running `mkdir .git/safe` in the root of repositories you trust lets us just type `rspec`, have the binstub be invoked, and therefore the correct version of RSpec be used for the project. rbenv/rbenv#309 We previously used `./bin/stubs` as our binstubs directory convention and ignored the directory in version control. We used that convention instead of `./bin` because we didn't want to gitignore the already-existing `./bin` directory and we didn't want to replace the critical `bin/rails`. The community is moving towards a convention of using `./bin`: * Rails is using `./bin` instead of `./script` starting with Rails 4. * The default Bundler behavior is to use `./bin`.
- Loading branch information...
Showing with 7 additions and 2 deletions.