Skip to content

Commit

Permalink
Refactor with RuboCop::RSpec::ExampleGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Jul 1, 2020
1 parent d5d8f82 commit 28660a7
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions lib/rubocop/cop/rspec/let_setup.rb
Expand Up @@ -57,27 +57,13 @@ def unused_let_bang(node)
end

def child_let_bang(node)
child_block_until_group(node) do |child|
node_with_name = let_bang(child)
lets = RuboCop::RSpec::ExampleGroup.new(node).lets

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
Expand Down

0 comments on commit 28660a7

Please sign in to comment.