Eliminate the bundle exec from Execution Command

1st and preffered method is to use RVM 1.11.x or greater.

You can check RVM version using above command:

  rvm -v

also can update:

  rvm get head && rvm reload

Now you can run test cases using

  rspec spec/

and omit the leading bundle exec.

2nd, in case you are restricted to use earlier version of rvm for any reason then:
use RVM Bundler integration to configure the Ruby Version Manager to include the proper executables automatically in the local environment. The steps are simple if somewhat mysterious. First, run these two commands:

  rvm get head && rvm reload
  chmod +x $rvm_path/hooks/after_cd_bundler
  cd ~/rails_project
  bundle install --without production --binstubs=./bundler_stubs

such that rake and rspec are automatically executed in the right environment.
These files are specific to your local setup, you should add the bundler_stubs directory to your .gitignore file

# Ignore other unneeded files.
doc/
*.swp
*~
.project
.DS_Store
bundler_stubs/

If you add another executable (such as guard in Section 3.6.2), you should re-run the bundle install command:

bundle install --binstubs=./bundler_stubs

3rd, If you are not using RVM, you can still avoid typing bundle exec. Bundler allows the creation of the associated binaries as follows:

bundle --binstubs

(In fact, this step, with a different target directory, is also used when using RVM.) This command creates all the necessary executables in the bin/ directory of the application, so that we can now run the test suite as follows:

bin/rspec spec/

The same goes for rake, etc.:

bin/rake db:migrate

If you add another executable (such as guard in Section 3.6.2), you should re-run the bundle –binstubs command.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s