diff --git a/lib/rubocop/cop/rspec/let_setup.rb b/lib/rubocop/cop/rspec/let_setup.rb index 5609af12d..867936b15 100644 --- a/lib/rubocop/cop/rspec/let_setup.rb +++ b/lib/rubocop/cop/rspec/let_setup.rb @@ -57,27 +57,12 @@ def unused_let_bang(node) end def child_let_bang(node) - child_block_until_group(node) do |child| - node_with_name = let_bang(child) + RuboCop::RSpec::ExampleGroup.new(node).lets.each do |let| + node_with_name = let_bang(let) yield node_with_name if node_with_name end end - - def child_block_until_group(node, &blk) - return unless node.body - - unwrap_nested_begin(node).each_child_node(:block) do |child| - next if example_or_shared_group_or_including?(child) - - yield child - child_block_until_group(child, &blk) - end - end - - def unwrap_nested_begin(node) - node.body.begin_type? ? node.body : node - end end end end