Heroku could not detect rake tasks (LoadError: cannot load such file - rspec / core / rake_task)

I am using travisCI to deploy to heroku and I am getting this error. He just started to happen.

I have a main rakefile rail, and I have a file that looks like travis cannot detect rake tasks:

# lib\tasks\spec.rake require 'rspec/core/rake_task' RSpec::Core::RakeTask.new task :default => :spec 

Why will this error be displayed specifically for heroku?

EDIT - I had a similar version (better):

 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 
+7
source share
3 answers

If rspec is not in the production group (this is usually not the case), then the code you submitted failed to run in the production environment, such as heroku.

In rspec docs, they recommend doing this:

 begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) rescue LoadError end 

Thus, the absence of rspec does not stop rakefile loading.

+8
source

You can edit your gemfile to add rspec gem to the production team. For instance.

 group :production, :test do gem 'rspec-rails', '~> 3.5' end 
0
source

FWIW, I just ran into the same problem. I fixed this by moving rspec-rails into production as shown below. I don't know why this works, but it works for me.

 group :production, :development, :test do gem 'rspec-rails', '~> 3.8' end 
0
source

Source: https://habr.com/ru/post/985463/


All Articles