Heroku could not detect rake tasks (LoadError: cannot load such file -- rspec/core/rake_task)
If rspec isn't in the production group (it generally isn't) then the code you posted would fail when run in a production environment like heroku.
In the rspec docs they recommend doing this:
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
end
So that the absence of rspec doesn't stop your rakefile loading.
FWIW, I just faced the same issue. I fixed it by moving rspec-rails
to production as shown below. I don't know why it works, but it works for me.
group :production, :development, :test do
gem 'rspec-rails', '~> 3.8'
end