Skip to content

Commit

Permalink
Make hook scopes and runners non-configurable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pirj committed Nov 2, 2022
1 parent c55aaac commit 744918d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 0 additions & 12 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ RSpec:
- Expectations
- Helpers
- Hooks
- HookScopes
- Runners
- Subjects
ExampleGroups:
inherit_mode:
Expand Down Expand Up @@ -81,12 +79,6 @@ RSpec:
- prepend_after
- after
- append_after
HookScopes:
- each
- example
- context
- all
- suite
Includes:
inherit_mode:
merge:
Expand All @@ -98,10 +90,6 @@ RSpec:
- include_examples
Context:
- include_context
Runners:
- to
- to_not
- not_to
SharedGroups:
inherit_mode:
merge:
Expand Down
6 changes: 4 additions & 2 deletions lib/rubocop/rspec/language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 744918d

Please sign in to comment.