lenjador 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,84 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Lenjador::Utils do
4
- let(:now) { Time.utc(2015, 10, 11, 23, 10, 21, 123456) }
5
-
6
- before do
7
- allow(Time).to receive(:now) { now }
8
- end
9
-
10
- describe '.build_event' do
11
- subject(:event) { described_class.build_event(metadata, level, application_name) }
12
-
13
- let(:application_name) { 'test_service' }
14
- let(:level) { :info }
15
- let(:metadata) { {x: 'y'} }
16
-
17
- it 'includes it in the event as application' do
18
- expect(event[:application]).to eq(application_name)
19
- end
20
-
21
- it 'includes log level' do
22
- expect(event[:level]).to eq(:info)
23
- end
24
-
25
- it 'includes timestamp' do
26
- expect(event[:@timestamp]).to eq('2015-10-11T23:10:21.123Z')
27
- end
28
-
29
- context 'when @timestamp provided' do
30
- let(:metadata) { {message: 'test', :@timestamp => 'a timestamp'} }
31
-
32
- it 'overwrites @timestamp' do
33
- expect(subject[:message]).to eq('test')
34
- expect(subject[:@timestamp]).to eq('a timestamp')
35
- end
36
- end
37
-
38
- context 'when host provided' do
39
- let(:metadata) { {message: 'test', host: 'xyz'} }
40
-
41
- it 'overwrites host' do
42
- expect(subject[:message]).to eq('test')
43
- expect(subject[:host]).to eq('xyz')
44
- end
45
- end
46
- end
47
-
48
- describe '.serialize_time_objects!' do
49
- let(:object) do
50
- {
51
- time: Time.now,
52
- hash: {
53
- time: Time.now
54
- },
55
- array: [
56
- Time.now,
57
- {
58
- time: Time.now
59
- }
60
- ]
61
- }
62
- end
63
-
64
- let(:serialized_time) { now.iso8601 }
65
-
66
- it 'recursively serializes time objects to iso8601' do
67
- o = object.dup
68
- described_class.serialize_time_objects!(o)
69
-
70
- expect(o).to eq(
71
- time: serialized_time,
72
- hash: {
73
- time: serialized_time
74
- },
75
- array: [
76
- serialized_time,
77
- {
78
- time: serialized_time
79
- }
80
- ]
81
- )
82
- end
83
- end
84
- end