Sha256: 331c37a377a6e2abcdb59d43ce0ae2489b20caeff6991924cb55340648737774
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
require_relative 'test_helper' # Unit Test for SemanticLogger::Appender::Bugsnag # class AppenderBugsnagTest < Minitest::Test describe SemanticLogger::Appender::Bugsnag do before do @appender = SemanticLogger::Appender::Bugsnag.new(:warn) @message = 'AppenderBugsnagTest log message' end (SemanticLogger::LEVELS - [:warn, :error]).each do |level| it "not send :#{level} notifications to Bugsnag" do message = hash = nil Bugsnag.stub(:notify, -> msg, h { message = msg; hash = h }) do @appender.send(level, "AppenderBugsnagTest #{level.to_s} message") end assert_nil message assert_nil hash end end it "send error notifications to Bugsnag with severity" do message = hash = nil Bugsnag.stub(:notify, -> msg, h { message = msg; hash = h }) do @appender.error @message end assert_equal RuntimeError.new(@message), message assert_equal 'error', hash[:severity] end it 'send warn notifications to Bugsnag replace warn severity with warning' do message = hash = nil Bugsnag.stub(:notify, -> msg, h { message = msg; hash = h }) do @appender.warn @message end assert_equal RuntimeError.new(@message), message assert_equal 'warning', hash[:severity] end it 'send notification to Bugsnag with custom attributes' do message = hash = nil Bugsnag.stub(:notify, -> msg, h { message = msg; hash = h }) do @appender.error @message, {key1: 1, key2: 'a'} end assert_equal RuntimeError.new(@message), message assert_equal(1, hash[:key1], hash) assert_equal('a', hash[:key2], hash) end it 'send notification to Bugsnag with exception' do message = hash = nil error = RuntimeError.new('Hello World') Bugsnag.stub(:notify, -> msg, h { message = msg; hash = h }) do @appender.error error end assert_equal error, message end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
semantic_logger-2.16.0 | test/appender_bugsnag_test.rb |