Method: ActiveSupport::Testing::Assertions#assert_raises
- Defined in:
- activesupport/lib/active_support/testing/assertions.rb
#assert_raises(*exp, match: nil, &block) ⇒ Object Also known as: assert_raise
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
34 35 36 37 38 |
# 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.) if match error end |