class RuboCop::Cop::Minitest::AssertRaisesWithRegexpArgument
assert_match(/some message/, exception.message)
end
obj.occur_error
exception = assert_raises FooError do
# good
end
obj.occur_error
assert_raises FooError, /some message/ do
# bad
@example
to match against a regular expression.
The raised exception is returned and can be used
Either way, it’s not the argument that ‘exception.message` is compared to.
Optionally the last argument can be a custom message string to help explain failures.
Arguments should be exception classes.
Checks for `assert_raises` with arguments of regular expression literals.
def on_send(node)
def on_send(node) add_offense(node) if node.last_argument&.regexp_type? end