Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add document for Department #1824

Merged
merged 1 commit into from Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
@@ -1,6 +1,7 @@
* xref:index.adoc[Home]
* xref:installation.adoc[Installation]
* xref:usage.adoc[Usage]
* xref:departments.adoc[Departments]
* xref:cops.adoc[Cops]
* xref:upgrade_to_version_2.adoc[Upgrade to 2.x]
* xref:third_party_rspec_syntax_extensions.adoc[RSpec syntax extensions in third-party gems]
Expand Down
80 changes: 80 additions & 0 deletions docs/modules/ROOT/pages/departments.adoc
@@ -0,0 +1,80 @@
= Departments

RuboCop RSpec currently has four departments:

* xref:cops_rspec.adoc[RSpec]: This department checks for RSpec-specific code style.
* xref:cops_rspec_capybara.adoc[RSpec/Capybara]: This department checks for Capybara-specific code style.
* xref:cops_rspec_factorybot.adoc[RSpec/FactoryBot]: This department checks for factory_bot-specific code style.
* xref:cops_rspec_rails.adoc[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:

[source,yaml]
----
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:

[cols="1, 1, 1"]
|===
|Department |Extract to |Status

|RSpec/Capybara
|https://github.com/rubocop/rubocop-capybara[rubocop-capybara]
|Extracted in https://github.com/rubocop/rubocop-rspec/releases/tag/v2.18.0[v2.18.0]

|RSpec/FactoryBot
|https://github.com/rubocop/rubocop-factory_bot[rubocop-factory_bot]
|Extracted in https://github.com/rubocop/rubocop-rspec/releases/tag/v2.22.0[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:

[source,ruby]
----
# Gemfile
group :test do
gem 'rubocop-rspec'
gem 'rubocop-capybara'
end
----

[source,yaml]
----
Capybara:
Enabled: true
----

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

[source,yaml]
----
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.:

[source,yaml]
----
RSpec/Capybara:
Enabled: false
RSpec/FactoryBot:
Enabled: false
----