From 744918d9e61e4964feb83a5b28931c8a70cab55f Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Thu, 3 Nov 2022 00:10:41 +0300 Subject: [PATCH] Make hook scopes and runners non-configurable As opposed to other RSpec DSL elements, there is no obvious way of configuring aliases for them. It doesn't make sense to expose them in the configuration file, as those won't ever be configured by users. --- CHANGELOG.md | 1 + config/default.yml | 12 ------------ lib/rubocop/rspec/language.rb | 6 ++++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c14c609..51325954d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix `RSpec/FactoryBot/ConsistentParenthesesStyle` to ignore calls without the first positional argument. ([@pirj]) - Fix `RSpec/FactoryBot/ConsistentParenthesesStyle` to ignore calls inside a Hash or an Array. ([@pirj]) - Fix `RSpec/NestedGroups` to correctly use `AllowedGroups` config. ([@samrjenkins]) +- Remove `Runners` and `HookScopes` RSpec DSL elements from configuration. ([@pirj]) ## 2.14.2 (2022-10-25) diff --git a/config/default.yml b/config/default.yml index 992e30424..a69408f87 100644 --- a/config/default.yml +++ b/config/default.yml @@ -12,8 +12,6 @@ RSpec: - Expectations - Helpers - Hooks - - HookScopes - - Runners - Subjects ExampleGroups: inherit_mode: @@ -81,12 +79,6 @@ RSpec: - prepend_after - after - append_after - HookScopes: - - each - - example - - context - - all - - suite Includes: inherit_mode: merge: @@ -98,10 +90,6 @@ RSpec: - include_examples Context: - include_context - Runners: - - to - - to_not - - not_to SharedGroups: inherit_mode: merge: diff --git a/lib/rubocop/rspec/language.rb b/lib/rubocop/rspec/language.rb index 8e9461ac8..382882ad0 100644 --- a/lib/rubocop/rspec/language.rb +++ b/lib/rubocop/rspec/language.rb @@ -135,8 +135,9 @@ def self.all(element) end module HookScopes # :nodoc: + ALL = %i[each example context all suite].freeze def self.all(element) - Language.config['HookScopes'].include?(element.to_s) + ALL.include?(element) end end @@ -158,8 +159,9 @@ def context(element) end module Runners # :nodoc: + ALL = %i[to to_not not_to].freeze def self.all(element) - Language.config['Runners'].include?(element.to_s) + ALL.include?(element) end end