spec/logger_spec.rb in ougai-1.6.4 vs spec/logger_spec.rb in ougai-1.6.5

- old
+ new

@@ -126,9 +126,37 @@ expect(item).to be_log_message('No message', log_level) expect(item).to include_data(data_id: 109, action: 'dump') end end + context 'with data that can respond to_hash' do + it 'outputs valid' do + class Dummy + def to_hash + { foo: 1 } + end + end + + logger.send(method, Dummy.new) + expect(item).to be_log_message('No message', log_level) + expect(item).to include_data(foo: 1) + end + end + + context 'with data that cannot respond to_hash' do + it '(array) outputs valid' do + logger.send(method, ['bar', 2]) + expect(item).to be_log_message('No message', log_level) + expect(item).to include_data(data: ['bar', 2]) + end + + it '(number) outputs valid' do + logger.send(method, 999) + expect(item).to be_log_message('No message', log_level) + expect(item).to include_data(data: 999) + end + end + context 'with message and data' do it 'outputs valid' do logger.send(method, log_msg, data_id: 99, action: 'insert') expect(item).to be_log_message(log_msg, log_level) expect(item).to include_data(data_id: 99, action: 'insert')