diff --git a/CHANGELOG.md b/CHANGELOG.md index f65e661fc..6cc79a3c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Add new `RSpec/IdenticalEqualityAssertion` cop. ([@tejasbubane][]) * Add `RSpec/Rails/AvoidSetupHook` cop. ([@paydaylight][]) * Fix false negative in `RSpec/ExpectChange` cop with block style and chained method call. ([@tejasbubane][]) +* Fix `Include` configuration for sub-departments. ([@pirj][]) ## 2.3.0 (2021-04-28) diff --git a/config/default.yml b/config/default.yml index fe526a173..92862f510 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,10 +1,10 @@ --- RSpec: Enabled: true - Include: + Include: &1 - "**/*_spec.rb" - "**/spec/**/*" - Language: + Language: &2 ExampleGroups: Regular: - describe @@ -698,6 +698,11 @@ RSpec/Yield: VersionAdded: '1.32' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield +RSpec/Capybara: + Enabled: true + Include: *1 + Language: *2 + RSpec/Capybara/CurrentPathExpectation: Description: Checks that no expectations are set on Capybara's `current_path`. Enabled: true @@ -720,6 +725,11 @@ RSpec/Capybara/VisibilityMatcher: VersionChanged: '2.0' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher +RSpec/FactoryBot: + Enabled: true + Include: *1 + Language: *2 + RSpec/FactoryBot/AttributeDefinedStatically: Description: Always declare attribute values as blocks. Enabled: true @@ -759,6 +769,11 @@ RSpec/FactoryBot/FactoryClassName: VersionChanged: '2.0' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName +RSpec/Rails: + Enabled: true + Include: *1 + Language: *2 + RSpec/Rails/AvoidSetupHook: Description: Checks that tests use RSpec `before` hook over Rails `setup` method. Enabled: pending diff --git a/lib/rubocop/rspec/config_formatter.rb b/lib/rubocop/rspec/config_formatter.rb index bf8c0f2a3..8207f40d7 100644 --- a/lib/rubocop/rspec/config_formatter.rb +++ b/lib/rubocop/rspec/config_formatter.rb @@ -7,6 +7,7 @@ module RSpec # Builds a YAML config file from two config hashes class ConfigFormatter EXTENSION_ROOT_DEPARTMENT = %r{^(RSpec/)}.freeze + SUBDEPARTMENTS = %[RSpec/Capybara RSpec/FactoryBot RSpec/Rails] STYLE_GUIDE_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/' def initialize(config, descriptions) @@ -24,6 +25,8 @@ def dump def unified_config cops.each_with_object(config.dup) do |cop, unified| + next if SUBDEPARTMENTS.include?(cop) + unified[cop] = config.fetch(cop) .merge(descriptions.fetch(cop)) .merge('StyleGuide' => STYLE_GUIDE_BASE_URL + cop.sub('RSpec/', '')) diff --git a/spec/project/default_config_spec.rb b/spec/project/default_config_spec.rb index 2a349f881..e5414e0f2 100644 --- a/spec/project/default_config_spec.rb +++ b/spec/project/default_config_spec.rb @@ -29,7 +29,7 @@ end let(:config_keys) do - cop_names + %w[RSpec] + cop_names + %w[RSpec RSpec/Capybara RSpec/FactoryBot RSpec/Rails] end def cop_configuration(config_key)