ougai 1.9.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/logging_spec.rb DELETED
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Ougai::Logging do
4
- subject do
5
- m = described_class
6
-
7
- Class.new do
8
- include m
9
-
10
- def level
11
- -1
12
- end
13
- end.new
14
- end
15
-
16
- describe '#weak_merge!' do
17
- it 'merges with unique elements in array' do
18
- result = nil
19
- subject.instance_eval do
20
- result = weak_merge!({ foo: [1, 2], bar: 'base', baz: ['A'] },
21
- { foo: [2, 3], bar: 'inferior', baz: ['B'] })
22
- end
23
- expect(result[:foo]).to eq([2, 3, 1])
24
- expect(result[:bar]).to eq('base')
25
- expect(result[:baz]).to eq(['B', 'A'])
26
- end
27
- end
28
-
29
- describe '#chain' do
30
- it 'is not implemented' do
31
- expect{ subject.chain(:arg1, :arg2, :arg3, :arg4) }.to raise_error(NotImplementedError)
32
- end
33
- end
34
-
35
- describe '#append' do
36
- it 'is not implemented' do
37
- expect{ subject.send(:append, :arg1, :arg2) }.to raise_error(NotImplementedError)
38
- end
39
- end
40
-
41
- describe '#add' do
42
- context 'severity is specified level' do
43
- it 'calls append with specified level' do
44
- data = double('data')
45
- expect(subject).to receive(:append).with(::Logger::Severity::DEBUG, ['debug message', data, nil])
46
- subject.add(::Logger::Severity::DEBUG, 'debug message', data)
47
- end
48
- end
49
-
50
- context 'severity is nil' do
51
- it 'calls append with UNKNOWN level' do
52
- expect(subject).to receive(:append).with(::Logger::Severity::UNKNOWN, ['message', nil, nil])
53
- subject.add(nil, 'message')
54
- end
55
- end
56
-
57
- context 'with block that yields message' do
58
- it 'calls append with yielded message' do
59
- expect(subject).to receive(:append).with(::Logger::Severity::WARN, 'block message')
60
- subject.add(::Logger::Severity::WARN) { 'block message' }
61
- end
62
- end
63
-
64
- context 'with block that yields array' do
65
- it 'calls append with yielded array' do
66
- data = double('data')
67
- expect(subject).to receive(:append).with(::Logger::Severity::WARN, ['block message', data])
68
- subject.add(::Logger::Severity::WARN) { ['block message', data] }
69
- end
70
- end
71
- end
72
-
73
- describe '#log' do
74
- context 'severity is specified' do
75
- it 'calls append with specified level' do
76
- ex = Exception.new
77
- expect(subject).to receive(:append).with(::Logger::Severity::FATAL, ['fatal message', ex, nil])
78
- subject.log(::Logger::Severity::FATAL, 'fatal message', ex)
79
- end
80
- end
81
-
82
- context 'severity is nil' do
83
- it 'calls append with UNKNOWN level' do
84
- expect(subject).to receive(:append).with(::Logger::Severity::UNKNOWN, ['message', nil, nil])
85
- subject.log(nil, 'message')
86
- end
87
- end
88
-
89
- context 'with block' do
90
- it 'calls append with yielded arguments' do
91
- ex = Exception.new
92
- data = double('data')
93
- expect(subject).to receive(:append).with(::Logger::Severity::INFO, ['block message', ex, data])
94
- subject.log(::Logger::Severity::INFO) { ['block message', ex, data] }
95
- end
96
- end
97
- end
98
- end
data/spec/ougai_spec.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Ougai do
4
- it 'has a version number' do
5
- expect(Ougai::VERSION).not_to be nil
6
- end
7
- end
data/spec/spec_helper.rb DELETED
@@ -1,78 +0,0 @@
1
- require 'timecop'
2
- require 'simplecov'
3
- SimpleCov.start do
4
- add_filter "/spec/"
5
- end
6
-
7
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
8
- require 'ougai'
9
-
10
- RSpec.shared_examples 'formatter#initialize' do |params|
11
- describe '#initialize' do
12
- let(:app_name) { 'dummy app name' }
13
- let(:hostname) { 'dummyhost' }
14
- let(:options) { params[:options] }
15
-
16
- subject { described_class.new(*arguments) }
17
-
18
- context 'with app_name' do
19
- let!(:arguments) { [app_name] }
20
-
21
- it 'creates an instance with valid app_name and hostname' do
22
- expect(subject.app_name).to eq(app_name)
23
- expect(subject.hostname).to eq(Socket.gethostname.force_encoding('UTF-8'))
24
- params[:default_opts].each do |key, val|
25
- expect(subject.send(key)).to eq(val)
26
- end
27
- end
28
- end
29
-
30
- context 'with options' do
31
- let!(:arguments) { [options] }
32
-
33
- it 'creates an instance with valid values for attributes' do
34
- expect(subject.app_name).to eq('rspec')
35
- expect(subject.hostname).to eq(Socket.gethostname.force_encoding('UTF-8'))
36
- options.each do |key, val|
37
- expect(subject.send(key)).to eq(val)
38
- end
39
- end
40
- end
41
-
42
- context 'with app_name and hostname' do
43
- let!(:arguments) { [app_name, hostname] }
44
-
45
- it 'creates an instance with valid app_name and hostname' do
46
- expect(subject.app_name).to eq(app_name)
47
- expect(subject.hostname).to eq(hostname)
48
- params[:default_opts].each do |key, val|
49
- expect(subject.send(key)).to eq(val)
50
- end
51
- end
52
- end
53
-
54
- context 'with app_name and options' do
55
- let!(:arguments) { [app_name, options] }
56
-
57
- it 'creates an instance with valid values for attributes' do
58
- expect(subject.app_name).to eq(app_name)
59
- expect(subject.hostname).to eq(Socket.gethostname.force_encoding('UTF-8'))
60
- options.each do |key, val|
61
- expect(subject.send(key)).to eq(val)
62
- end
63
- end
64
- end
65
-
66
- context 'with app_name, hostname and options' do
67
- let!(:arguments) { [app_name, hostname, options] }
68
-
69
- it 'creates an instance with valid values for attributes' do
70
- expect(subject.app_name).to eq(app_name)
71
- expect(subject.hostname).to eq(hostname)
72
- options.each do |key, val|
73
- expect(subject.send(key)).to eq(val)
74
- end
75
- end
76
- end
77
- end
78
- end