Usage
You need to tell RuboCop to load the RSpec Rails extension. There are three ways to do this:
RuboCop configuration file
Put this into your .rubocop.yml
:
require: rubocop-rspec_rails
or, if you are using several extensions:
require: - rubocop-rspec - rubocop-rspec_rails
Now you can run rubocop
and it will automatically load the RuboCop RSpec Rails
cops together with the standard cops.
Inspecting files that don’t end with _spec.rb
By default, rubocop-rspec_rails
only inspects code within paths ending in _spec.rb
or including spec/
. You can override this setting in your config file by setting Include
:
# Inspect files in `test/` directory
RSpecRails:
Include:
- '**/test/**/*'
# Inspect only files ending with `_test.rb`
RSpecRails:
Include:
- '**/*_test.rb'
Please keep in mind that merge mode for Include is set to override the default settings, so if you intend to add a path while keeping the default paths, you should include the default Include paths in your configuration.
|