1st and preffered method is to use RVM 1.11.x or greater.
You can check RVM version using above command:
also can update:
rvm get head && rvm reload
Now you can run test cases using
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:
(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:
The same goes for rake, etc.:
If you add another executable (such as guard in Section 3.6.2), you should re-run the bundle –binstubs command.