method

assert_raises

rails latest stable - Class: ActiveSupport::Testing::Assertions
assert_raises(*exp, match: nil, &block)
public

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