Sha256: 3ffbedfbd7de882e4a906bff91d7bcc34c2932c9da5092a819a068f640047a77
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe RabbitmqClient::JsonFormatter do subject { described_class.new } let(:message) { 'Test loG message' } let(:global_store) { double('Store') } let(:time) { Time.now } let(:formated_time) { time.strftime('%Y-%m-%dT%H:%M:%S.%6N ') } before do RabbitmqClient.config.global_store = global_store end after do RabbitmqClient.config.global_store = nil end describe '.call' do it 'formatt the log message' do allow(global_store).to receive(:store).and_return({}) log_line = subject.call('DEBUG', time, nil, message) json_log = JSON.parse(log_line[0...-1]) expect(json_log).to eq( 'level' => 'DEBUG', 'message' => 'Test loG message', 'timestamp' => formated_time ) end it 'add tags to the log message' do allow(global_store).to receive(:store).and_return('x-request-id': '10') log_line = subject.call('DEBUG', time, nil, message) json_log = JSON.parse(log_line[0...-1]) expect(json_log).to eq( 'level' => 'DEBUG', 'message' => 'Test loG message', 'timestamp' => formated_time, 'x-request-id' => '10' ) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rabbitmq_client-0.0.3 | spec/json_formatter_spec.rb |
rabbitmq_client-0.0.2 | spec/json_formatter_spec.rb |
rabbitmq_client-0.0.1 | spec/json_formatter_spec.rb |