test/measure_test.rb in semantic_logger-4.2.0 vs test/measure_test.rb in semantic_logger-4.2.1
- old
+ new
@@ -44,22 +44,22 @@
end
end
it ':exception' do
assert_raises RuntimeError do
- logger.send(measure_level, 'hello world', payload: payload) { raise RuntimeError.new('Test') }
+ logger.send(measure_level, 'hello world', payload: payload) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
assert_equal level, log.level
end
it ':on_exception_level' do
assert_raises RuntimeError do
- logger.measure(level, 'hello world', payload: payload, on_exception_level: :fatal) { raise RuntimeError.new('Test') }
+ logger.measure(level, 'hello world', payload: payload, on_exception_level: :fatal) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
@@ -67,21 +67,21 @@
end
describe 'log_exception' do
it 'default' do
assert_raises RuntimeError do
- logger.send(measure_level, 'hello world') { raise RuntimeError.new('Test') }
+ logger.send(measure_level, 'hello world') { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
end
it ':full' do
assert_raises RuntimeError do
- logger.send(measure_level, 'hello world', log_exception: :full) { raise RuntimeError.new('Test') }
+ logger.send(measure_level, 'hello world', log_exception: :full) { raise 'Test' }
end
assert log = log_message
assert log.exception.is_a?(RuntimeError)
assert log.exception.backtrace
@@ -89,21 +89,21 @@
assert_equal 'hello world', log.message
end
it ':partial' do
assert_raises RuntimeError do
- logger.send(measure_level, 'hello world', log_exception: :partial) { raise RuntimeError.new('Test') }
+ logger.send(measure_level, 'hello world', log_exception: :partial) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
end
it ':none' do
assert_raises RuntimeError do
- logger.send(measure_level, 'hello world', log_exception: :none) { raise RuntimeError.new('Test') }
+ logger.send(measure_level, 'hello world', log_exception: :none) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world', log.message
@@ -122,11 +122,11 @@
SemanticLogger.stub(:backtrace_level_index, 0) do
assert_equal 'result', logger.send(measure_level, 'hello world') { 'result' }
assert log = log_message
assert log.backtrace
- assert log.backtrace.size > 0
+ assert log.backtrace.size.positive?
# Extract file name and line number from backtrace
h = log.to_h
assert_match /measure_test.rb/, h[:file], h
assert h[:line].is_a?(Integer)
@@ -169,22 +169,22 @@
end
end
it ':exception' do
assert_raises RuntimeError do
- logger.measure(level, 'hello world', payload: payload) { raise RuntimeError.new('Test') }
+ logger.measure(level, 'hello world', payload: payload) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
assert_equal level, log.level
end
it ':on_exception_level' do
assert_raises RuntimeError do
- logger.measure(level, 'hello world', payload: payload, on_exception_level: :fatal) { raise RuntimeError.new('Test') }
+ logger.measure(level, 'hello world', payload: payload, on_exception_level: :fatal) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
@@ -203,11 +203,11 @@
SemanticLogger.stub(:backtrace_level_index, 0) do
assert_equal 'result', logger.measure(level, 'hello world') { 'result' }
assert log = log_message
assert log.backtrace
- assert log.backtrace.size > 0
+ assert log.backtrace.size.positive?
# Extract file name and line number from backtrace
h = log.to_h
assert_match /measure_test.rb/, h[:file], h
assert h[:line].is_a?(Integer)
@@ -251,22 +251,22 @@
end
end
it ':exception' do
assert_raises RuntimeError do
- logger.send(measure_level, message: 'hello world', payload: payload) { raise RuntimeError.new('Test') }
+ logger.send(measure_level, message: 'hello world', payload: payload) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
assert_equal level, log.level
end
it ':on_exception_level' do
assert_raises RuntimeError do
- logger.send(measure_level, message: 'hello world', payload: payload, on_exception_level: :fatal) { raise RuntimeError.new('Test') }
+ logger.send(measure_level, message: 'hello world', payload: payload, on_exception_level: :fatal) { raise 'Test' }
end
assert log = log_message
refute log.exception
assert_equal 'hello world -- Exception: RuntimeError: Test', log.message
@@ -285,20 +285,19 @@
SemanticLogger.stub(:backtrace_level_index, 0) do
assert_equal 'result', logger.send(measure_level, message: 'hello world') { 'result' }
assert log = log_message
assert log.backtrace
- assert log.backtrace.size > 0
+ assert log.backtrace.size.positive?
# Extract file name and line number from backtrace
h = log.to_h
assert_match /measure_test.rb/, h[:file], h
assert h[:line].is_a?(Integer)
end
end
end
-
end
describe 'return' do
it 'log when the block performs a return' do
assert_equal 'Good', function_with_return(logger)
@@ -341,8 +340,7 @@
logger.measure_info('hello world', payload: payload) do
return 'Good'
end
'Bad'
end
-
end
end