Skip to content

Commit

Permalink
Fix default config for sub-departments
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pirj committed Jun 30, 2021
1 parent e33f838 commit d3c48ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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)

Expand Down
13 changes: 12 additions & 1 deletion config/default.yml
@@ -1,5 +1,5 @@
---
RSpec:
RSpec: &rspec
Enabled: true
Include:
- "**/*_spec.rb"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/project/default_config_spec.rb
Expand Up @@ -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)
Expand Down

0 comments on commit d3c48ae

Please sign in to comment.