From f9fdf161ff0bfbc785a30d4eca5aa2580cd452e4 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Wed, 30 Jun 2021 19:06:41 +0300 Subject: [PATCH] Fix default config for sub-departments It turns out that the default config does not apply for sub-departments. It is weird on many levels: - RSpec DSL configuration didn't work - - RSpec DSL doesn't work as intended anyway #1126 - if users would re-define RSpec DSL, they would have to do it for all sub-departments, as YAML defaults are only for the default config - if users would re-define RSpec DSL and use YAML defaults, too, the merging of the resulting config is undetermined Still, I believe having `Include` to work correctly is the most important. fixes #1160 --- config/default.yml | 13 ++++++++++++- spec/project/default_config_spec.rb | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config/default.yml b/config/default.yml index fe526a173..39ca129bf 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,5 +1,5 @@ --- -RSpec: +RSpec: &rspec Enabled: true Include: - "**/*_spec.rb" @@ -698,6 +698,9 @@ RSpec/Yield: VersionAdded: '1.32' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Yield +RSpec/Capybara: + <<: *rspec + RSpec/Capybara/CurrentPathExpectation: Description: Checks that no expectations are set on Capybara's `current_path`. Enabled: true @@ -720,6 +723,9 @@ RSpec/Capybara/VisibilityMatcher: VersionChanged: '2.0' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Capybara/VisibilityMatcher +RSpec/FactoryBot: + <<: *rspec + RSpec/FactoryBot/AttributeDefinedStatically: Description: Always declare attribute values as blocks. Enabled: true @@ -759,6 +765,11 @@ RSpec/FactoryBot/FactoryClassName: VersionChanged: '2.0' StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/FactoryBot/FactoryClassName +RSpec/Rails: + Include: + - "**/*_spec.rb" + - "**/spec/**/*" + RSpec/Rails/AvoidSetupHook: Description: Checks that tests use RSpec `before` hook over Rails `setup` method. Enabled: pending 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)