This is quite a frustrating error which can be fixed easily. Whilst experimenting with a project I found that two main things can make a difference:
If your travis config file is not configured correctly then it may not be running bundler correctly. Here is our old bundler config:
install: bundle install --without development --deployment --jobs=3 --retry=3 cache: directories: - vendor/bundle
Because this was such a basic error I didn't even think to look in the Gemfile. The
rspec-rails gem was in the development group. So you can probably guess what was happening.
When travis did it's thing it wasn't including rspec in the bundle. Therefore it couldn't pick up the rspec rake task file.
As a footnote to this, we also found that adding a task in
lib\tasks\spec.rb helped. Below is a basic task for when travis won't load 'default':
## Required if CI fails default task require 'rspec/core/rake_task' RSpec::Core::RakeTask.new task :default => :spec