method

assert_error_reported

rails latest stable - Class: ActiveSupport::Testing::ErrorReporterAssertions
assert_error_reported(error_class = StandardError, &block)
public

Assertion that the block should cause at least one exception to be reported to Rails.error.

Passes if the evaluated code in the yielded block reports a matching exception.

assert_error_reported(IOError) do
  Rails.error.report(IOError.new("Oops"))
end

To test further details about the reported exception, you can use the return value.

report = assert_error_reported(IOError) do
  # ...
end
assert_equal "Oops", report.error.message
assert_equal "admin", report.context[:section]
assert_equal :warning, report.severity
assert_predicate report, :handled?