test/logger_test.rb in semantic_logger-4.2.0 vs test/logger_test.rb in semantic_logger-4.2.1
- old
+ new
@@ -9,11 +9,10 @@
{action: 'hit', user: 'jbloggs', state: 'FL'}
end
# Ensure that any log level can be logged
SemanticLogger::LEVELS.each do |level|
-
describe "##{level}" do
describe 'positional parameter' do
it 'logs message' do
logger.send(level, 'hello world')
@@ -42,11 +41,11 @@
assert log = log_message
assert_equal 'hello world -- Calculations', log.message
assert_equal payload, log.payload
assert log.backtrace
- assert log.backtrace.size > 0, log.backtrace
+ assert log.backtrace.size.positive?, log.backtrace
end
end
it 'logs with backtrace and exception' do
SemanticLogger.stub(:backtrace_level_index, 0) do
@@ -54,11 +53,11 @@
logger.send(level, 'hello world', exc)
assert log = log_message
assert_equal 'hello world', log.message
assert log.backtrace
- assert log.backtrace.size > 0, log.backtrace
+ assert log.backtrace.size.positive?, log.backtrace
assert log.exception
refute log.exception.backtrace
assert_equal 'RuntimeError', log.exception.class.name
end
@@ -151,42 +150,41 @@
end
describe '#filter' do
describe 'at the appender level' do
it 'Proc' do
- appender.filter = -> log { (/\AExclude/ =~ log.message).nil? }
+ appender.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
refute log_message
end
it 'RegExp' do
filter = /\ALogger/
- appender.filter = -> log { (/\AExclude/ =~ log.message).nil? }
+ appender.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
refute log_message
end
end
describe 'at the logger level' do
it 'Proc' do
- logger.filter = -> log { (/\AExclude/ =~ log.message).nil? }
+ logger.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
refute log_message
end
it 'RegExp' do
filter = /\ALogger/
- logger.filter = -> log { (/\AExclude/ =~ log.message).nil? }
+ logger.filter = ->(log) { (/\AExclude/ =~ log.message).nil? }
logger.send(level, 'Exclude this log message', @hash) { 'Calculations' }
refute log_message
end
end
-
end
end
end
describe 'when level is too high' do
@@ -202,13 +200,13 @@
# Ensure that any log level can be logged
Logger::Severity.constants.each do |level|
it "log Ruby logger #{level} info" do
logger.level = Logger::Severity.const_get(level)
if level.to_s == 'UNKNOWN'
- assert_equal Logger::Severity.const_get('ERROR')+1, logger.send(:level_index)
+ assert_equal Logger::Severity.const_get('ERROR') + 1, logger.send(:level_index)
else
- assert_equal Logger::Severity.const_get(level)+1, logger.send(:level_index)
+ assert_equal Logger::Severity.const_get(level) + 1, logger.send(:level_index)
end
end
end
end
@@ -259,11 +257,11 @@
logger.tagged('12345', 'DJHSFK') do
logger.info('hello world')
assert log = log_message
assert_equal 'hello world', log.message
- assert_equal %w(12345 DJHSFK), log.tags
+ assert_equal %w[12345 DJHSFK], log.tags
end
end
it 'add embedded tags to log entries' do
logger.tagged('First Level', 'tags') do
@@ -290,17 +288,16 @@
end
end
end
it 'is compatible with rails logging that uses arrays and nils' do
- logger.tagged('', ['12345', 'DJHSFK'], nil) do
+ logger.tagged('', %w[12345 DJHSFK], nil) do
logger.info('hello world')
assert log = log_message
assert_equal 'hello world', log.message
- assert_equal %w(12345 DJHSFK), log.tags
+ assert_equal %w[12345 DJHSFK], log.tags
end
end
end
-
end
end