test/appender/graylog_test.rb in semantic_logger-4.2.0 vs test/appender/graylog_test.rb in semantic_logger-4.2.1

- old
+ new

@@ -7,15 +7,15 @@ before do @appender = SemanticLogger::Appender::Graylog.new(level: :info) @message = 'AppenderGraylogTest log message' end - (SemanticLogger::LEVELS - [:info, :warn, :error, :fatal]).each do |level| + (SemanticLogger::LEVELS - %i[info warn error fatal]).each do |level| it "not send :#{level} notifications to Graylog" do hash = nil - @appender.notifier.stub(:notify!, -> h { hash = h }) do - @appender.send(level, "AppenderGraylogTest #{level.to_s} message") + @appender.notifier.stub(:notify!, ->(h) { hash = h }) do + @appender.send(level, "AppenderGraylogTest #{level} message") end assert_nil hash end end @@ -25,11 +25,11 @@ begin Uh oh rescue Exception => e exc = e end - @appender.notifier.stub(:notify!, -> h { hash = h }) do + @appender.notifier.stub(:notify!, ->(h) { hash = h }) do @appender.error 'Reading File', exc end assert_equal 'Reading File', hash[:short_message] assert_equal 'NameError', hash[:exception][:name] assert_match 'undefined local variable or method', hash[:exception][:message] @@ -43,11 +43,11 @@ begin raise StandardError, 'Reading File' rescue Exception => e exc = e end - @appender.notifier.stub(:notify!, -> h { hash = h }) do + @appender.notifier.stub(:notify!, ->(h) { hash = h }) do @appender.error exc end assert_equal exc.message, hash[:short_message] assert_equal exc.class.to_s, hash[:exception][:name] assert_match exc.message, hash[:exception][:message] @@ -55,21 +55,21 @@ assert hash[:exception][:stack_trace].first.include?(__FILE__), hash[:exception] end it 'send error notifications to Graylog with severity' do hash = nil - @appender.notifier.stub(:notify!, -> h { hash = h }) do + @appender.notifier.stub(:notify!, ->(h) { hash = h }) do @appender.error @message end assert_equal @message, hash[:short_message] assert_equal 3, hash[:level] refute hash[:stack_trace] end it 'send notification to Graylog with custom attributes' do hash = nil - @appender.notifier.stub(:notify!, -> h { hash = h }) do - @appender.error @message, {key1: 1, key2: 'a'} + @appender.notifier.stub(:notify!, ->(h) { hash = h }) do + @appender.error @message, key1: 1, key2: 'a' end assert_equal @message, hash[:short_message] assert_equal 3, hash[:level] refute hash[:stack_trace] assert payload = hash[:payload], hash