RSpec/Rails/InferredSpecType doesn't check to see if you're actually using Rails
bunnymatic opened this issue · comments
We're working on a Sinatra app.
When we have RSpec/Rails/InferredSpecType
enabled (by default) and we run auto correct, it removes all the type: :whatever_type
params from specs. But because we're not in Rails, those inferred types don't actually apply.
If I try adding
describe MyDomain::App, type: :feature do
... tests here
end
Autocorrect makes it
describe MyDomain::App do
... tests here
end
And if I try adding infer_spec_type_from_file_location!
which works on a Rails app, I get
An error occurred while loading ./spec/whatever_spec.rb.
Failure/Error: config.infer_spec_type_from_file_location!
NoMethodError:
undefined method `infer_spec_type_from_file_location!'
Feels like rubocop-rspec
should check to see if Rails is involved before enforcing and auto correcting that rule.
We can disable the rule for now but it feels like a workaround.
Relevant gems/versions
rubocop-rspec 2.24.1
ruby 3.1.3
Sinatra 3.1.0
gem info rubocop-rspec [23:51:47]
*** LOCAL GEMS ***
rubocop-rspec (2.24.1)
Authors: John Backus, Ian MacLeod, Nils Gemeinhardt
Homepage: https://github.com/rubocop/rubocop-rspec
License: MIT
Installed at:...3.1.3/lib/ruby/gems/3.1.0
Code style checking for RSpec files
We plan on extracting rubocop-rspec_rails. It won’t be included by default with rubocop-rspec.
I suggest you to configure your project to only run relevant cops. And you can skip whole departments:
RSpec/Rails:
Enable: false
Thanks for the tip. Didn't realize you can skip a bucket like that.