Method: RuboCop::Cop::RSpec::MultipleExpectations#on_block

Defined in:
lib/rubocop/cop/rspec/multiple_expectations.rb

#on_block(node) ⇒ Object

rubocop:disable InternalAffairs/NumblockHandler

[View source]

93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/rubocop/cop/rspec/multiple_expectations.rb', line 93

def on_block(node) # rubocop:disable InternalAffairs/NumblockHandler
  return unless example?(node)

  return if example_with_aggregate_failures?(node)

  expectations_count = to_enum(:find_expectation, node).count

  return if expectations_count <= max_expectations

  self.max = expectations_count

  flag_example(node, expectation_count: expectations_count)
end