rspec / rspec-support

Common code needed by the other RSpec gems. Not intended for direct use.
https://rspec.info
MIT License
99 stars 102 forks source link

Prevent Rakefile from loading rubocop when dependency is not present #396

Closed bjfish closed 4 years ago

bjfish commented 4 years ago

I encountered the following error:

% bundle exec rake spec
rake aborted!
cannot load such file -- rubocop/rake_task

because the Gemfile has the following condition for including this dependency:

if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby'
  gem "rubocop", "~> 0.52.1"
end

So, I've added the same condition to the Rakefile.

pirj commented 4 years ago

It seems there's no consistency in how we define rubocop task across projects.

rspec-expectations:

if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby'
  require 'rubocop/rake_task'
  RuboCop::RakeTask.new(:rubocop)
end

if RUBY_VERSION >= '2.4' && RUBY_ENGINE == 'ruby'
  task :default => [:spec, :cucumber, :rubocop]
else

rspec-core:

desc 'Run RuboCop on the lib directory'
task :rubocop do
  sh 'bundle exec rubocop lib'
end

Do you plan to touch those Rakefiles as well @bjfish ?

bjfish commented 4 years ago

@pirj I'd probably leave them alone unless I had some issue. They appear they'd work as is for my use case: bundle exec rake spec.

JonRowe commented 4 years ago

@pirj I think it was done to limit what rubocop is applied to, but it also addresses this issue in a different way.