Skip to content

Commit

Permalink
Add document for Department
Browse files Browse the repository at this point in the history
Fix: #1823
  • Loading branch information
ydah committed Mar 1, 2024
1 parent a9bb3f5 commit 0b391ce
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
----

0 comments on commit 0b391ce

Please sign in to comment.