Skip to content

Commit

Permalink
Refactor NamedSubject to use Language module (rubocop#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darhazer authored and Filipp Pirozhkov committed Nov 8, 2017
1 parent bd8a3fa commit 497cd88
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/rubocop/cop/rspec/named_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class NamedSubject < Cop
'to reference it explicitly.'.freeze

def_node_matcher :rspec_block?, <<-PATTERN
(block
(send nil {:it :specify :before :after :around} ...)
...)
{
#{Examples::ALL.block_pattern}
#{Hooks::ALL.block_pattern}
}
PATTERN

def_node_matcher :unnamed_subject, '$(send nil :subject)'
Expand All @@ -60,11 +61,9 @@ def on_block(node)
private

def subject_usage(node, &block)
return unless node.is_a?(Parser::AST::Node)

unnamed_subject(node, &block)

node.children.each do |child|
node.each_child_node do |child|
subject_usage(child, &block)
end
end
Expand Down

0 comments on commit 497cd88

Please sign in to comment.