Usage

You need to tell RuboCop to load the Capybara extension. There are three ways to do this:

RuboCop configuration file

Put this into your .rubocop.yml:

require: rubocop-capybara

or, if you are using several extensions:

require:
  - rubocop-capybara
  - rubocop-performance

Now you can run rubocop and it will automatically load the RuboCop Capybara cops together with the standard cops.

Command line

$ rubocop --require rubocop-capybara

Rake task

RuboCop::RakeTask.new do |task|
  task.requires << 'rubocop-capybara'
end

Inspecting files that don’t end with _spec.rb

By default, rubocop-capybara 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
Capybara:
  Include:
    - '**/test/**/*'
# Inspect only files ending with `_test.rb`
Capybara:
  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.