I'm using travisCI to deploy to heroku and I am getting this error. It has only just started happening.
I have the basic rails Rakefile and I have a file that looks like this as otherwise travis cannot detect the rake tasks:
# lib\tasks\spec.rake
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
task :default => :spec
Why would this error be displaying specifically for heroku?
EDIT - I had a similar version to the (better) answer given:
begin
require 'rspec/core/rake_task'
desc "Run all examples"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
t.pattern = 'spec/*_spec.rb'
end
rescue LoadError
end
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With