Departments

RuboCop RSpec currently has four departments:

  • RSpec: This department checks for RSpec-specific code style.

  • RSpec/Capybara: This department checks for Capybara-specific code style.

  • RSpec/FactoryBot: This department checks for factory_bot-specific code style.

  • RSpec/Rails: This department checks for RSpec-specific code style in Rails applications.

Each department has its own set of cops. You can enable or disable individual cops within each department. If your project doesn’t use factory_bot, and uses Sinatra and not Rails, you can disable the RSpec/FactoryBot and RSpec/Rails departments in your .rubocop.yml file:

RSpec/FactoryBot:
  Enabled: false

RSpec/Rails:
  Enabled: false

Planned to extract to separate gems

There are plans for extracting the following three departments before RuboCop RSpec v3.0:

Department Extract to Status

RSpec/Capybara

rubocop-capybara

Extracted in v2.18.0

RSpec/FactoryBot

rubocop-factory_bot

Extracted in v2.22.0

RSpec/Rails

rubocop-rspec-rails

Not yet extracted

Migration manual

If you are using the RSpec/Capybara, RSpec/FactoryBot, or RSpec/Rails departments, you need to install the corresponding gem and add it to your .rubocop.yml file.

For example, if you are using the RSpec/Capybara department, you need to install the rubocop-capybara gem and add it to your .rubocop.yml file:

# Gemfile
group :test do
  gem 'rubocop-rspec'
  gem 'rubocop-capybara'
end
Capybara:
  Enabled: true

And you need to disable the old department in your .rubocop.yml file:

RSpec/Capybara:
  Enabled: false

For another example, if you are not using these departments, you don’t need to do anything. And when you update to RuboCop RSpec v3.0.0, you need to remove the old departments from your .rubocop.yml file, e.g.:

RSpec/Capybara:
  Enabled: false
RSpec/FactoryBot:
  Enabled: false