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

File paths to be inspected

By default, rubocop-capybara only inspects code in files whose paths match the following regular expression.

Capybara:
  Include:
    - '**/*_spec.rb'
    - '**/spec/**/*'
    - '**/test/**/*'
    - '**/*_steps.rb'
    - '**/features/step_definitions/**/*'

You can override this setting in your config file by setting Include:

# Inspect files in `inspection/` directory
Capybara:
  Include:
    - '**/inspection/**/*'
# Inspect only files ending with `_inspection.rb`
Capybara:
  Include:
    - '**/*_inspection.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.