lib/rubocop/cop/rspec/named_subject.rb in rubocop-rspec-1.15.1 vs lib/rubocop/cop/rspec/named_subject.rb in rubocop-rspec-1.16.0
- old
+ new
@@ -40,13 +40,14 @@
class NamedSubject < Cop
MSG = 'Name your test subject if you need '\
'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)'
def on_block(node)
@@ -58,14 +59,12 @@
end
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
end
end