Skip to content

Commit

Permalink
Merge pull request #934 from mockdeep/rf-shared_groups
Browse files Browse the repository at this point in the history
Pull example group node matchers up
  • Loading branch information
bquorning committed Jul 1, 2020
2 parents 7e2d6dc + b327884 commit 172dfe8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions lib/rubocop/cop/rspec/describe_class.rb
Expand Up @@ -51,8 +51,6 @@ class DescribeClass < Cop
)
PATTERN

def_node_matcher :shared_group?, SharedGroups::ALL.block_pattern

def on_top_level_describe(node, (described_value, _))
return if shared_group?(root_node)
return if valid_describe?(node)
Expand Down
5 changes: 1 addition & 4 deletions lib/rubocop/cop/rspec/leaky_constant_declaration.rb
Expand Up @@ -119,11 +119,8 @@ def on_module(node)
private

def inside_describe_block?(node)
node.each_ancestor(:block).any?(&method(:in_example_or_shared_group?))
node.each_ancestor(:block).any?(&method(:spec_group?))
end

def_node_matcher :in_example_or_shared_group?,
(ExampleGroups::ALL + SharedGroups::ALL).block_pattern
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/rubocop/rspec/language/node_pattern.rb
Expand Up @@ -8,6 +8,10 @@ module NodePattern
extend RuboCop::NodePattern::Macros

def_node_matcher :example_group?, ExampleGroups::ALL.block_pattern
def_node_matcher :shared_group?, SharedGroups::ALL.block_pattern

spec_groups = ExampleGroups::ALL + SharedGroups::ALL
def_node_matcher :spec_group?, spec_groups.block_pattern

def_node_matcher :example_group_with_body?, <<-PATTERN
(block #{ExampleGroups::ALL.send_pattern} args [!nil?])
Expand Down

0 comments on commit 172dfe8

Please sign in to comment.