lib/rubocop/cop/rspec/leading_subject.rb in rubocop-rspec-1.43.1 vs lib/rubocop/cop/rspec/leading_subject.rb in rubocop-rspec-1.43.2

- old
+ new

@@ -52,14 +52,18 @@ end private def offending_node(node) - node.parent.each_child_node.find do |sibling| + parent(node).each_child_node.find do |sibling| break if sibling.equal?(node) yield sibling if offending?(sibling) end + end + + def parent(node) + node.each_ancestor(:block).first.body end def autocorrect(corrector, node, sibling) RuboCop::RSpec::Corrector::MoveNode.new( node, corrector, processed_source