lib/rubocop/cop/rspec/leading_subject.rb in rubocop-rspec-1.27.0 vs lib/rubocop/cop/rspec/leading_subject.rb in rubocop-rspec-1.28.0
- old
+ new
@@ -35,15 +35,10 @@
include RangeHelp
MSG = 'Declare `subject` above any other `%<offending>s` ' \
'declarations.'.freeze
- def_node_matcher :subject?, Subject::ALL.block_pattern
- def_node_matcher :let?, Helpers::ALL.block_pattern
- def_node_matcher :hook?, Hooks::ALL.block_pattern
- def_node_matcher :example?, Examples::ALL.block_pattern
-
def on_block(node)
return unless subject?(node) && !in_spec_block?(node)
check_previous_nodes(node)
end
@@ -86,10 +81,10 @@
range_by_whole_lines(node.source_range, include_final_newline: true)
end
def in_spec_block?(node)
node.each_ancestor(:block).any? do |ancestor|
- Examples::ALL.include?(ancestor.method_name)
+ example?(ancestor)
end
end
end
end
end