Class: RuboCop::Cop::RSpec::MultipleExpectations
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::RSpec::MultipleExpectations
- Includes:
- ConfigurableMax, RSpec::Language, RSpec::SpecOnly
- Defined in:
- lib/rubocop/cop/rspec/multiple_expectations.rb
Overview
Checks if examples contain too many ‘expect` calls.
This cop is configurable using the ‘Max` option and works with `–auto-gen-config`.
Constant Summary collapse
- MSG =
'Too many expectations.'.freeze
Constants included from RSpec::SpecOnly
RSpec::SpecOnly::DEFAULT_CONFIGURATION
Constants included from RSpec::Language
Instance Method Summary collapse
Methods included from RSpec::SpecOnly
Instance Method Details
#on_block(node) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/rubocop/cop/rspec/multiple_expectations.rb', line 61 def on_block(node) return unless example?(node) && (expectations = expect(node)) return if expectations.count <= max_expectations self.max = expectations.count flag_example(node, expectation_count: expectations.count) end |