instance method
assert_raises
Ruby on Rails 7.2.3
Since v7.1.6Signature
assert_raises(*exp, match: nil, &block)
Asserts that a block raises one of exp. This is an enhancement of the standard Minitest assertion method with the ability to test error messages.
assert_raises(ArgumentError, match: /incorrect param/i) do perform_service(param: 'exception') end
Parameters
-
exprest -
matchkey = nil -
blockblock
Source
# File activesupport/lib/active_support/testing/assertions.rb, line 34
def assert_raises(*exp, match: nil, &block)
error = super(*exp, &block)
assert_match(match, error.message) if match
error
end
Defined in activesupport/lib/active_support/testing/assertions.rb line 34
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Testing::Assertions