commit 17a9b85204ad14c0d499fe8e2de14bf5a49162cd Author: František Dvořák Date: Sat Aug 23 21:13:39 2014 +0200 Remove LogStash::Time from tests to work with logstash-event >= 1.2. diff --git a/spec/lib/logstasher/log_subscriber_spec.rb b/spec/lib/logstasher/log_subscriber_spec.rb index c376bb7..4b46eb2 100644 --- a/spec/lib/logstasher/log_subscriber_spec.rb +++ b/spec/lib/logstasher/log_subscriber_spec.rb @@ -43,10 +43,10 @@ describe LogStasher::RequestLogSubscriber do let(:payload) { {} } let(:event) { double(:payload => payload) } let(:logger) { double } - let(:json) { "{\"@source\":\"unknown\",\"@tags\":[\"request\"],\"@fields\":{\"request\":true,\"status\":true,\"runtimes\":true,\"location\":true,\"exception\":true,\"custom\":true},\"@timestamp\":\"timestamp\"}\n" } + let(:json) { "{\"@source\":\"unknown\",\"@fields\":{\"request\":true,\"status\":true,\"runtimes\":true,\"location\":true,\"exception\":true,\"custom\":true},\"@tags\":[\"request\"],\"@timestamp\":\"1970-01-01T00:00:00Z\",\"@version\":\"1\"}\n" } before do allow(LogStasher).to receive(:logger).and_return(logger) - allow(LogStash::Time).to receive(:now).and_return('timestamp') + allow(Time).to receive(:now).and_return(Time.gm(1970,1,1)) end it 'calls all extractors and outputs the json' do expect(request_subscriber).to receive(:extract_request).with(payload).and_return({:request => true}) diff --git a/spec/lib/logstasher_spec.rb b/spec/lib/logstasher_spec.rb index c9bc57a..85ceb0f 100644 --- a/spec/lib/logstasher_spec.rb +++ b/spec/lib/logstasher_spec.rb @@ -195,12 +195,12 @@ describe LogStasher do let(:logger) { double() } before do LogStasher.logger = logger - allow(LogStash::Time).to receive_messages(:now => 'timestamp') + allow(Time).to receive_messages(:now => Time.gm(1970,1,1)) allow_message_expectations_on_nil end it 'adds to log with specified level' do expect(logger).to receive(:send).with('warn?').and_return(true) - expect(logger).to receive(:send).with('warn',"{\"@source\":\"unknown\",\"@tags\":[\"log\"],\"@fields\":{\"message\":\"WARNING\",\"level\":\"warn\"},\"@timestamp\":\"timestamp\"}") + expect(logger).to receive(:send).with('warn',"{\"@source\":\"unknown\",\"@fields\":{\"message\":\"WARNING\",\"level\":\"warn\"},\"@tags\":[\"log\"],\"@timestamp\":\"1970-01-01T00:00:00Z\",\"@version\":\"1\"}") LogStasher.log('warn', 'WARNING') end context 'with a source specified' do @@ -209,7 +209,7 @@ describe LogStasher do end it 'sets the correct source' do expect(logger).to receive(:send).with('warn?').and_return(true) - expect(logger).to receive(:send).with('warn',"{\"@source\":\"foo\",\"@tags\":[\"log\"],\"@fields\":{\"message\":\"WARNING\",\"level\":\"warn\"},\"@timestamp\":\"timestamp\"}") + expect(logger).to receive(:send).with('warn',"{\"@source\":\"foo\",\"@fields\":{\"message\":\"WARNING\",\"level\":\"warn\"},\"@tags\":[\"log\"],\"@timestamp\":\"1970-01-01T00:00:00Z\",\"@version\":\"1\"}") LogStasher.log('warn', 'WARNING') end end