lib/rubocop/cop/rspec/empty_example_group.rb in rubocop-rspec-2.22.0 vs lib/rubocop/cop/rspec/empty_example_group.rb in rubocop-rspec-2.23.0
- old
+ new
@@ -129,10 +129,11 @@
# @return [Array<RuboCop::AST::Node>] matching nodes
def_node_matcher :examples?, <<~PATTERN
{
#examples_directly_or_in_block?
(begin <#examples_directly_or_in_block? ...>)
+ (begin <#examples_in_branches? ...>)
}
PATTERN
def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
return if node.each_ancestor(:def, :defs).any?
@@ -167,9 +168,11 @@
examples_in_branches?(condition_node)
end
end
def examples_in_branches?(condition_node)
+ return if !condition_node.if_type? && !condition_node.case_type?
+
condition_node.branches.any? { |branch| examples?(branch) }
end
def removed_range(node)
range_by_whole_lines(