Sha256: 34fa7db4a13d1eb18f98d17bdfb5484e05c41c2eca2e5f181433bbc5796df621
Contents?: true
Size: 1.65 KB
Versions: 4
Compression:
Stored size: 1.65 KB
Contents
require_relative '../test_helper' # Unit Test for SemanticLogger::Appender::Sentry module Appender class SentryTest < Minitest::Test describe SemanticLogger::Appender::Sentry do before do @appender = SemanticLogger::Appender::Sentry.new(level: :trace) @message = 'AppenderRavenTest log message' SemanticLogger.backtrace_level = :error end SemanticLogger::LEVELS.each do |level| it "sends #{level} message" do error_message = hash = nil Raven.stub(:capture_message, ->(msg, h) { error_message = msg; hash = h }) do @appender.send(level, @message) end assert_equal @message, error_message assert_equal 'SemanticLogger::Appender::Sentry', hash[:extra][:name] if %i[error fatal].include?(level) assert hash[:extra].key?(:backtrace) else refute hash[:extra].key?(:backtrace) end assert_equal true, hash.key?(:extra) assert_equal level, hash[:level] end it "sends #{level} exceptions" do error = RuntimeError.new('Oh no, Error.') exception = hash = nil Raven.stub(:capture_exception, ->(exc, h) { exception = exc; hash = h }) do @appender.send(level, @message, error) end assert_equal error.class.to_s, exception.class.to_s assert_equal error.message, exception.message assert_equal true, hash.key?(:extra) assert_equal @message, hash[:extra][:message], hash assert_equal level, hash[:level] end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems