Class: RuboCop::Cop::RSpec::UnspecifiedException
- Defined in:
- lib/rubocop/cop/rspec/unspecified_exception.rb
Overview
Checks for a specified error in checking raised errors.
Enforces one of an Exception type, a string, or a regular expression to match against the exception message as a parameter to ‘raise_error`
Constant Summary collapse
- MSG =
'Specify the exception being captured'
Constants inherited from Cop
Cop::DEFAULT_CONFIGURATION, Cop::DEFAULT_PATTERN_RE
Constants included from RSpec::Language
RSpec::Language::ALL, RSpec::Language::RSPEC
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#block_with_args?(node) ⇒ Boolean
58 59 60 61 62 |
# File 'lib/rubocop/cop/rspec/unspecified_exception.rb', line 58 def block_with_args?(node) return unless node&.block_type? node.arguments? end |
#empty_exception_matcher?(node) ⇒ Boolean
54 55 56 |
# File 'lib/rubocop/cop/rspec/unspecified_exception.rb', line 54 def empty_exception_matcher?(node) empty_raise_error_or_exception(node) && !block_with_args?(node.parent) end |
#on_send(node) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/rubocop/cop/rspec/unspecified_exception.rb', line 45 def on_send(node) return unless empty_exception_matcher?(node) add_offense( node.children.last, location: :expression ) end |