class RuboCop::Cop::RSpec::UnspecifiedException

expect { do_something }.not_to raise_error
}.to raise_error(/err/)
raise StandardError.new(‘error’)
expect {
}.to raise_error(‘error’)
raise StandardError.new(‘error’)
expect {
}.to raise_error(StandardError)
raise StandardError.new(‘error’)
expect {
# good
}.to raise_error
raise StandardError.new(‘error’)
expect {
# bad
@example
to ‘raise_error`
expression to match against the exception message as a parameter
Enforces one of an Exception type, a string, or a regular
Checks for a specified error in checking raised errors.

def block_with_args?(node)

def block_with_args?(node)
  return unless node&.block_type?
  node.arguments?
end

def empty_exception_matcher?(node)

def empty_exception_matcher?(node)
  empty_raise_error_or_exception(node) && !block_with_args?(node.parent)
end

def on_send(node)

def on_send(node)
  return unless empty_exception_matcher?(node)
  add_offense(node.children.last)
end