Skip to content
  • Andrew Novoselac's avatar
    22dd98ad
    Introduce ActiveSupport::Testing::ErrorReporterAssertions#capture_error_reports · 22dd98ad
    Andrew Novoselac authored
    Captures all reported errors from within the block that match the given
    error class.
    
    reports = capture_reported_errors(IOError) do
        Rails.error.report(IOError.new("Oops"))
        Rails.error.report(IOError.new("Oh no"))
        Rails.error.report(StandardError.new)
    end
    
    assert_equal 2, reports.size
    assert_equal "Oops", reports.first.error.message
    assert_equal "Oh no", reports.last.error.message
    22dd98ad
    Introduce ActiveSupport::Testing::ErrorReporterAssertions#capture_error_reports
    Andrew Novoselac authored
    Captures all reported errors from within the block that match the given
    error class.
    
    reports = capture_reported_errors(IOError) do
        Rails.error.report(IOError.new("Oops"))
        Rails.error.report(IOError.new("Oh no"))
        Rails.error.report(StandardError.new)
    end
    
    assert_equal 2, reports.size
    assert_equal "Oops", reports.first.error.message
    assert_equal "Oh no", reports.last.error.message
Loading