airbrake-ruby 5.0.1-java → 5.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby.rb +4 -2
- data/lib/airbrake-ruby/async_sender.rb +3 -1
- data/lib/airbrake-ruby/config.rb +15 -6
- data/lib/airbrake-ruby/config/processor.rb +7 -20
- data/lib/airbrake-ruby/context.rb +51 -0
- data/lib/airbrake-ruby/file_cache.rb +1 -1
- data/lib/airbrake-ruby/filter_chain.rb +2 -0
- data/lib/airbrake-ruby/filters/context_filter.rb +4 -5
- data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/git_revision_filter.rb +1 -1
- data/lib/airbrake-ruby/filters/keys_filter.rb +2 -2
- data/lib/airbrake-ruby/filters/sql_filter.rb +2 -2
- data/lib/airbrake-ruby/filters/thread_filter.rb +2 -3
- data/lib/airbrake-ruby/grouppable.rb +1 -1
- data/lib/airbrake-ruby/ignorable.rb +0 -2
- data/lib/airbrake-ruby/mergeable.rb +1 -1
- data/lib/airbrake-ruby/notice_notifier.rb +3 -4
- data/lib/airbrake-ruby/performance_notifier.rb +1 -2
- data/lib/airbrake-ruby/remote_settings.rb +10 -50
- data/lib/airbrake-ruby/remote_settings/callback.rb +44 -0
- data/lib/airbrake-ruby/remote_settings/settings_data.rb +3 -8
- data/lib/airbrake-ruby/tdigest.rb +7 -6
- data/lib/airbrake-ruby/thread_pool.rb +5 -3
- data/lib/airbrake-ruby/timed_trace.rb +1 -3
- data/lib/airbrake-ruby/version.rb +2 -2
- data/spec/airbrake_spec.rb +139 -76
- data/spec/async_sender_spec.rb +10 -8
- data/spec/backtrace_spec.rb +13 -10
- data/spec/benchmark_spec.rb +5 -3
- data/spec/code_hunk_spec.rb +24 -15
- data/spec/config/processor_spec.rb +29 -87
- data/spec/config/validator_spec.rb +5 -2
- data/spec/config_spec.rb +26 -17
- data/spec/context_spec.rb +54 -0
- data/spec/deploy_notifier_spec.rb +6 -4
- data/spec/file_cache_spec.rb +1 -0
- data/spec/filter_chain_spec.rb +29 -24
- data/spec/filters/context_filter_spec.rb +14 -5
- data/spec/filters/dependency_filter_spec.rb +3 -1
- data/spec/filters/exception_attributes_filter_spec.rb +5 -3
- data/spec/filters/gem_root_filter_spec.rb +5 -2
- data/spec/filters/git_last_checkout_filter_spec.rb +10 -12
- data/spec/filters/git_repository_filter.rb +9 -9
- data/spec/filters/git_revision_filter_spec.rb +19 -19
- data/spec/filters/keys_allowlist_spec.rb +25 -16
- data/spec/filters/keys_blocklist_spec.rb +25 -18
- data/spec/filters/root_directory_filter_spec.rb +3 -3
- data/spec/filters/sql_filter_spec.rb +26 -26
- data/spec/filters/system_exit_filter_spec.rb +4 -2
- data/spec/filters/thread_filter_spec.rb +16 -14
- data/spec/loggable_spec.rb +2 -2
- data/spec/monotonic_time_spec.rb +8 -6
- data/spec/nested_exception_spec.rb +46 -46
- data/spec/notice_notifier/options_spec.rb +23 -13
- data/spec/notice_notifier_spec.rb +52 -47
- data/spec/notice_spec.rb +6 -2
- data/spec/performance_notifier_spec.rb +67 -60
- data/spec/promise_spec.rb +38 -32
- data/spec/remote_settings/callback_spec.rb +162 -0
- data/spec/remote_settings/settings_data_spec.rb +23 -53
- data/spec/remote_settings_spec.rb +42 -75
- data/spec/response_spec.rb +34 -12
- data/spec/stashable_spec.rb +5 -5
- data/spec/stat_spec.rb +7 -5
- data/spec/sync_sender_spec.rb +49 -16
- data/spec/tdigest_spec.rb +61 -56
- data/spec/thread_pool_spec.rb +65 -55
- data/spec/time_truncate_spec.rb +4 -2
- data/spec/timed_trace_spec.rb +32 -30
- data/spec/truncator_spec.rb +72 -43
- metadata +53 -47
data/spec/async_sender_spec.rb
CHANGED
@@ -13,18 +13,20 @@ RSpec.describe Airbrake::AsyncSender do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#send" do
|
16
|
+
subject(:async_sender) { described_class.new }
|
17
|
+
|
16
18
|
context "when sender has the capacity to send" do
|
17
19
|
it "sends notices to Airbrake" do
|
18
|
-
2.times {
|
19
|
-
|
20
|
+
2.times { async_sender.send(notice, Airbrake::Promise.new) }
|
21
|
+
async_sender.close
|
20
22
|
|
21
23
|
expect(a_request(:post, endpoint)).to have_been_made.twice
|
22
24
|
end
|
23
25
|
|
24
26
|
it "returns a resolved promise" do
|
25
27
|
promise = Airbrake::Promise.new
|
26
|
-
|
27
|
-
|
28
|
+
async_sender.send(notice, promise)
|
29
|
+
async_sender.close
|
28
30
|
|
29
31
|
expect(promise).to be_resolved
|
30
32
|
end
|
@@ -40,8 +42,8 @@ RSpec.describe Airbrake::AsyncSender do
|
|
40
42
|
end
|
41
43
|
|
42
44
|
it "doesn't send the exceeded notices to Airbrake" do
|
43
|
-
15.times {
|
44
|
-
|
45
|
+
15.times { async_sender.send(notice, Airbrake::Promise.new) }
|
46
|
+
async_sender.close
|
45
47
|
|
46
48
|
expect(a_request(:post, endpoint)).not_to have_been_made
|
47
49
|
end
|
@@ -49,9 +51,9 @@ RSpec.describe Airbrake::AsyncSender do
|
|
49
51
|
it "returns a rejected promise" do
|
50
52
|
promise = nil
|
51
53
|
15.times do
|
52
|
-
promise =
|
54
|
+
promise = async_sender.send(notice, Airbrake::Promise.new)
|
53
55
|
end
|
54
|
-
|
56
|
+
async_sender.close
|
55
57
|
|
56
58
|
expect(promise).to be_rejected
|
57
59
|
expect(promise.value).to eq(
|
data/spec/backtrace_spec.rb
CHANGED
@@ -177,10 +177,13 @@ RSpec.describe Airbrake::Backtrace do
|
|
177
177
|
end
|
178
178
|
|
179
179
|
it "logs frames that cannot be parsed" do
|
180
|
-
|
180
|
+
allow(Airbrake::Loggable.instance).to receive(:error)
|
181
|
+
|
182
|
+
described_class.parse(ex)
|
183
|
+
|
184
|
+
expect(Airbrake::Loggable.instance).to have_received(:error).with(
|
181
185
|
/can't parse 'a b c 1 23 321 .rb'/,
|
182
186
|
)
|
183
|
-
described_class.parse(ex)
|
184
187
|
end
|
185
188
|
end
|
186
189
|
|
@@ -298,9 +301,9 @@ RSpec.describe Airbrake::Backtrace do
|
|
298
301
|
it "attaches code to those frames files of which match root_directory" do
|
299
302
|
ex = RuntimeError.new
|
300
303
|
backtrace = [
|
301
|
-
project_root_path('code.rb')
|
302
|
-
fixture_path(
|
303
|
-
project_root_path('vendor/bundle/ignored_file.rb')
|
304
|
+
"#{project_root_path('code.rb')}:94:in `to_json'",
|
305
|
+
fixture_path("notroot.txt:3:in `pineapple'"),
|
306
|
+
"#{project_root_path('vendor/bundle/ignored_file.rb')}:2:in `ignore_me'",
|
304
307
|
]
|
305
308
|
ex.set_backtrace(backtrace)
|
306
309
|
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
@@ -335,7 +338,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
335
338
|
|
336
339
|
it "attaches code to those frames files of which match root_directory" do
|
337
340
|
ex = RuntimeError.new
|
338
|
-
ex.set_backtrace([project_root_path('code.rb')
|
341
|
+
ex.set_backtrace(["#{project_root_path('code.rb')}:94:in `to_json'"])
|
339
342
|
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
340
343
|
end
|
341
344
|
end
|
@@ -387,9 +390,9 @@ RSpec.describe Airbrake::Backtrace do
|
|
387
390
|
it "attaches code to first N frames" do
|
388
391
|
ex = RuntimeError.new
|
389
392
|
backtrace = [
|
390
|
-
project_root_path('code.rb')
|
391
|
-
project_root_path('code.rb')
|
392
|
-
project_root_path('code.rb')
|
393
|
+
"#{project_root_path('code.rb')}:94:in `to_json'",
|
394
|
+
"#{project_root_path('code.rb')}:95:in `to_json'",
|
395
|
+
"#{project_root_path('code.rb')}:96:in `to_json'",
|
393
396
|
]
|
394
397
|
ex.set_backtrace(backtrace)
|
395
398
|
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
@@ -417,7 +420,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
417
420
|
|
418
421
|
it "doesn't attach code to frames" do
|
419
422
|
ex = RuntimeError.new
|
420
|
-
backtrace = [project_root_path('code.rb')
|
423
|
+
backtrace = ["#{project_root_path('code.rb')}:94:in `to_json'"]
|
421
424
|
ex.set_backtrace(backtrace)
|
422
425
|
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
423
426
|
end
|
data/spec/benchmark_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
RSpec.describe Airbrake::Benchmark do
|
2
|
+
subject(:benchmark) { described_class.new }
|
3
|
+
|
2
4
|
describe ".measure" do
|
3
5
|
it "returns measured performance time" do
|
4
6
|
expect(described_class.measure { '10' * 10 }).to be_kind_of(Numeric)
|
@@ -6,14 +8,14 @@ RSpec.describe Airbrake::Benchmark do
|
|
6
8
|
end
|
7
9
|
|
8
10
|
describe "#stop" do
|
9
|
-
before {
|
11
|
+
before { benchmark }
|
10
12
|
|
11
13
|
context "when called one time" do
|
12
14
|
its(:stop) { is_expected.to eq(true) }
|
13
15
|
end
|
14
16
|
|
15
17
|
context "when called twice or more" do
|
16
|
-
before {
|
18
|
+
before { benchmark.stop }
|
17
19
|
|
18
20
|
its(:stop) { is_expected.to eq(false) }
|
19
21
|
end
|
@@ -25,7 +27,7 @@ RSpec.describe Airbrake::Benchmark do
|
|
25
27
|
end
|
26
28
|
|
27
29
|
context "when #stop was called" do
|
28
|
-
before {
|
30
|
+
before { benchmark.stop }
|
29
31
|
|
30
32
|
its(:duration) { is_expected.to be > 0 }
|
31
33
|
end
|
data/spec/code_hunk_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
RSpec.describe Airbrake::CodeHunk do
|
2
|
+
subject(:code_hunk) { described_class.new }
|
3
|
+
|
2
4
|
after do
|
3
5
|
%w[empty_file.rb code.rb banana.rb short_file.rb long_line.txt].each do |f|
|
4
6
|
Airbrake::FileCache[project_root_path(f)] = nil
|
@@ -27,10 +29,12 @@ RSpec.describe Airbrake::CodeHunk do
|
|
27
29
|
end
|
28
30
|
|
29
31
|
context "when a file has less than NLINES lines before start line" do
|
30
|
-
subject
|
32
|
+
subject(:code_hunk) do
|
33
|
+
described_class.new.get(project_root_path('code.rb'), 1)
|
34
|
+
end
|
31
35
|
|
32
36
|
it do
|
33
|
-
|
37
|
+
expect(code_hunk).to(
|
34
38
|
eq(
|
35
39
|
1 => 'module Airbrake',
|
36
40
|
2 => ' ##',
|
@@ -43,10 +47,12 @@ RSpec.describe Airbrake::CodeHunk do
|
|
43
47
|
end
|
44
48
|
|
45
49
|
context "when a file has less than NLINES lines after end line" do
|
46
|
-
subject
|
50
|
+
subject(:code_hunk) do
|
51
|
+
described_class.new.get(project_root_path('code.rb'), 222)
|
52
|
+
end
|
47
53
|
|
48
54
|
it do
|
49
|
-
|
55
|
+
expect(code_hunk).to(
|
50
56
|
eq(
|
51
57
|
220 => ' end',
|
52
58
|
221 => 'end',
|
@@ -56,12 +62,12 @@ RSpec.describe Airbrake::CodeHunk do
|
|
56
62
|
end
|
57
63
|
|
58
64
|
context "when a file has less than NLINES lines before and after" do
|
59
|
-
subject do
|
65
|
+
subject(:code_hunk) do
|
60
66
|
described_class.new.get(project_root_path('short_file.rb'), 2)
|
61
67
|
end
|
62
68
|
|
63
69
|
it do
|
64
|
-
|
70
|
+
expect(code_hunk).to(
|
65
71
|
eq(
|
66
72
|
1 => 'module Banana',
|
67
73
|
2 => ' attr_reader :bingo',
|
@@ -72,10 +78,12 @@ RSpec.describe Airbrake::CodeHunk do
|
|
72
78
|
end
|
73
79
|
|
74
80
|
context "when a file has enough lines before and after" do
|
75
|
-
subject
|
81
|
+
subject(:code_hunk) do
|
82
|
+
described_class.new.get(project_root_path('code.rb'), 100)
|
83
|
+
end
|
76
84
|
|
77
85
|
it do
|
78
|
-
|
86
|
+
expect(code_hunk).to(
|
79
87
|
eq(
|
80
88
|
98 => ' return json if json && json.bytesize <= MAX_NOTICE_SIZE',
|
81
89
|
99 => ' end',
|
@@ -88,27 +96,28 @@ RSpec.describe Airbrake::CodeHunk do
|
|
88
96
|
end
|
89
97
|
|
90
98
|
context "when a line exceeds the length limit" do
|
91
|
-
subject do
|
99
|
+
subject(:code_hunk) do
|
92
100
|
described_class.new.get(project_root_path('long_line.txt'), 1)
|
93
101
|
end
|
94
102
|
|
95
103
|
it "strips the line" do
|
96
|
-
expect(
|
104
|
+
expect(code_hunk[1]).to eq("l#{'o' * 196}ng")
|
97
105
|
end
|
98
106
|
end
|
99
107
|
|
100
108
|
context "when an error occurrs while fetching code" do
|
101
109
|
before do
|
102
|
-
|
110
|
+
allow(Airbrake::Loggable.instance).to receive(:error)
|
111
|
+
allow(Airbrake::FileCache).to receive(:[]).and_raise(Errno::EACCES)
|
103
112
|
end
|
104
113
|
|
105
114
|
it "logs error and returns nil" do
|
106
|
-
expect(
|
107
|
-
/can't read code hunk.+Permission denied/,
|
108
|
-
)
|
109
|
-
expect(subject.get(project_root_path('code.rb'), 1)).to(
|
115
|
+
expect(code_hunk.get(project_root_path('code.rb'), 1)).to(
|
110
116
|
eq(1 => ''),
|
111
117
|
)
|
118
|
+
expect(Airbrake::Loggable.instance).to have_received(:error).with(
|
119
|
+
/can't read code hunk.+Permission denied/,
|
120
|
+
)
|
112
121
|
end
|
113
122
|
end
|
114
123
|
end
|
@@ -44,23 +44,49 @@ RSpec.describe Airbrake::Config::Processor do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "#process_remote_configuration" do
|
47
|
+
before do
|
48
|
+
allow(Airbrake::RemoteSettings).to receive(:poll)
|
49
|
+
end
|
50
|
+
|
47
51
|
context "when the config doesn't define a project_id" do
|
48
52
|
let(:config) { Airbrake::Config.new(project_id: nil) }
|
49
53
|
|
50
54
|
it "doesn't set remote settings" do
|
51
|
-
expect(Airbrake::RemoteSettings).not_to receive(:poll)
|
52
55
|
described_class.new(config).process_remote_configuration
|
56
|
+
|
57
|
+
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when the config sets environment to 'test'" do
|
62
|
+
let(:config) { Airbrake::Config.new(project_id: 123, environment: 'test') }
|
63
|
+
|
64
|
+
it "doesn't set remote settings" do
|
65
|
+
described_class.new(config).process_remote_configuration
|
66
|
+
|
67
|
+
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
53
68
|
end
|
54
69
|
end
|
55
70
|
|
56
71
|
context "when the config defines a project_id" do
|
57
72
|
let(:config) do
|
58
|
-
Airbrake::Config.new(project_id: 123)
|
73
|
+
Airbrake::Config.new(project_id: 123, environment: 'not-test')
|
59
74
|
end
|
60
75
|
|
61
76
|
it "sets remote settings" do
|
62
|
-
expect(Airbrake::RemoteSettings).to receive(:poll)
|
63
77
|
described_class.new(config).process_remote_configuration
|
78
|
+
|
79
|
+
expect(Airbrake::RemoteSettings).to have_received(:poll)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when the config disables the remote_config option" do
|
84
|
+
let(:config) { Airbrake::Config.new(project_id: 123, remote_config: false) }
|
85
|
+
|
86
|
+
it "doesn't set remote settings" do
|
87
|
+
described_class.new(config).process_remote_configuration
|
88
|
+
|
89
|
+
expect(Airbrake::RemoteSettings).not_to have_received(:poll)
|
64
90
|
end
|
65
91
|
end
|
66
92
|
end
|
@@ -122,88 +148,4 @@ RSpec.describe Airbrake::Config::Processor do
|
|
122
148
|
end
|
123
149
|
end
|
124
150
|
end
|
125
|
-
|
126
|
-
describe "#poll_callback" do
|
127
|
-
let(:logger) { Logger.new(File::NULL) }
|
128
|
-
|
129
|
-
let(:config) do
|
130
|
-
Airbrake::Config.new(
|
131
|
-
project_id: 123,
|
132
|
-
logger: logger,
|
133
|
-
)
|
134
|
-
end
|
135
|
-
|
136
|
-
let(:data) do
|
137
|
-
instance_double(Airbrake::RemoteSettings::SettingsData)
|
138
|
-
end
|
139
|
-
|
140
|
-
before do
|
141
|
-
allow(data).to receive(:to_h)
|
142
|
-
allow(data).to receive(:error_host)
|
143
|
-
allow(data).to receive(:apm_host)
|
144
|
-
allow(data).to receive(:error_notifications?)
|
145
|
-
allow(data).to receive(:performance_stats?)
|
146
|
-
end
|
147
|
-
|
148
|
-
it "logs given data" do
|
149
|
-
expect(logger).to receive(:debug).with(/applying remote settings/)
|
150
|
-
described_class.new(config).poll_callback(data)
|
151
|
-
end
|
152
|
-
|
153
|
-
it "sets the error_notifications option" do
|
154
|
-
config.error_notifications = false
|
155
|
-
expect(data).to receive(:error_notifications?).and_return(true)
|
156
|
-
|
157
|
-
described_class.new(config).poll_callback(data)
|
158
|
-
expect(config.error_notifications).to eq(true)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "sets the performance_stats option" do
|
162
|
-
config.performance_stats = false
|
163
|
-
expect(data).to receive(:performance_stats?).and_return(true)
|
164
|
-
|
165
|
-
described_class.new(config).poll_callback(data)
|
166
|
-
expect(config.performance_stats).to eq(true)
|
167
|
-
end
|
168
|
-
|
169
|
-
context "when error_host returns a value" do
|
170
|
-
it "sets the error_host option" do
|
171
|
-
config.error_host = 'http://api.airbrake.io'
|
172
|
-
allow(data).to receive(:error_host).and_return('https://api.example.com')
|
173
|
-
|
174
|
-
described_class.new(config).poll_callback(data)
|
175
|
-
expect(config.error_host).to eq('https://api.example.com')
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context "when error_host returns nil" do
|
180
|
-
it "doesn't modify the error_host option" do
|
181
|
-
config.error_host = 'http://api.airbrake.io'
|
182
|
-
allow(data).to receive(:error_host).and_return(nil)
|
183
|
-
|
184
|
-
described_class.new(config).poll_callback(data)
|
185
|
-
expect(config.error_host).to eq('http://api.airbrake.io')
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context "when apm_host returns a value" do
|
190
|
-
it "sets the apm_host option" do
|
191
|
-
config.apm_host = 'http://api.airbrake.io'
|
192
|
-
allow(data).to receive(:apm_host).and_return('https://api.example.com')
|
193
|
-
|
194
|
-
described_class.new(config).poll_callback(data)
|
195
|
-
expect(config.apm_host).to eq('https://api.example.com')
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
context "when apm_host returns nil" do
|
200
|
-
it "doesn't modify the apm_host option" do
|
201
|
-
config.apm_host = 'http://api.airbrake.io'
|
202
|
-
allow(data).to receive(:apm_host).and_return(nil)
|
203
|
-
|
204
|
-
described_class.new(config).poll_callback(data)
|
205
|
-
expect(config.apm_host).to eq('http://api.airbrake.io')
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
151
|
end
|
@@ -175,9 +175,12 @@ RSpec.describe Airbrake::Config::Validator do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it "warns about 'no effect'" do
|
178
|
-
|
179
|
-
|
178
|
+
allow(config.logger).to receive(:warn)
|
179
|
+
|
180
180
|
described_class.check_notify_ability(config)
|
181
|
+
|
182
|
+
expect(config.logger).to have_received(:warn)
|
183
|
+
.with(/'ignore_environments' has no effect/)
|
181
184
|
end
|
182
185
|
end
|
183
186
|
|
data/spec/config_spec.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
RSpec.describe Airbrake::Config do
|
2
|
+
subject(:config) { described_class.new }
|
3
|
+
|
2
4
|
let(:resolved_promise) { Airbrake::Promise.new.resolve }
|
3
5
|
let(:rejected_promise) { Airbrake::Promise.new.reject }
|
4
6
|
|
@@ -26,26 +28,31 @@ RSpec.describe Airbrake::Config do
|
|
26
28
|
its(:query_stats) { is_expected.to eq(true) }
|
27
29
|
its(:job_stats) { is_expected.to eq(true) }
|
28
30
|
its(:error_notifications) { is_expected.to eq(true) }
|
31
|
+
its(:remote_config) { is_expected.to eq(true) }
|
29
32
|
|
30
33
|
its(:remote_config_host) do
|
31
|
-
is_expected.to eq('https://
|
34
|
+
is_expected.to eq('https://notifier-configs.airbrake.io')
|
32
35
|
end
|
33
36
|
|
34
37
|
describe "#new" do
|
35
38
|
context "when user config is passed" do
|
36
39
|
subject { described_class.new(logger: StringIO.new) }
|
40
|
+
|
37
41
|
its(:logger) { is_expected.to be_a(StringIO) }
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
45
|
describe "#valid?" do
|
42
|
-
context "when
|
43
|
-
before
|
46
|
+
context "when the config is valid" do
|
47
|
+
before do
|
48
|
+
config.project_id = 123
|
49
|
+
config.project_key = 'abc'
|
50
|
+
end
|
51
|
+
|
44
52
|
it { is_expected.to be_valid }
|
45
53
|
end
|
46
54
|
|
47
|
-
context "when
|
48
|
-
before { expect(subject).to receive(:validate).and_return(rejected_promise) }
|
55
|
+
context "when the config is invalid" do
|
49
56
|
it { is_expected.not_to be_valid }
|
50
57
|
end
|
51
58
|
end
|
@@ -53,7 +60,7 @@ RSpec.describe Airbrake::Config do
|
|
53
60
|
describe "#ignored_environment?" do
|
54
61
|
context "when Validator returns a resolved promise" do
|
55
62
|
before do
|
56
|
-
|
63
|
+
allow(Airbrake::Config::Validator).to receive(:check_notify_ability)
|
57
64
|
.and_return(resolved_promise)
|
58
65
|
end
|
59
66
|
|
@@ -62,7 +69,7 @@ RSpec.describe Airbrake::Config do
|
|
62
69
|
|
63
70
|
context "when Validator returns a rejected promise" do
|
64
71
|
before do
|
65
|
-
|
72
|
+
allow(Airbrake::Config::Validator).to receive(:check_notify_ability)
|
66
73
|
.and_return(rejected_promise)
|
67
74
|
end
|
68
75
|
|
@@ -95,19 +102,21 @@ RSpec.describe Airbrake::Config do
|
|
95
102
|
end
|
96
103
|
|
97
104
|
describe "#check_configuration" do
|
98
|
-
let(:user_config) { {} }
|
99
|
-
|
100
105
|
subject { described_class.new(valid_params.merge(user_config)) }
|
101
106
|
|
107
|
+
let(:user_config) { {} }
|
108
|
+
|
102
109
|
its(:check_configuration) { is_expected.to be_an(Airbrake::Promise) }
|
103
110
|
|
104
111
|
context "when config is invalid" do
|
105
112
|
let(:user_config) { { project_id: nil } }
|
113
|
+
|
106
114
|
its(:check_configuration) { is_expected.to be_rejected }
|
107
115
|
end
|
108
116
|
|
109
117
|
context "when current environment is ignored" do
|
110
118
|
let(:user_config) { { environment: 'test', ignore_environments: ['test'] } }
|
119
|
+
|
111
120
|
its(:check_configuration) { is_expected.to be_rejected }
|
112
121
|
end
|
113
122
|
|
@@ -119,12 +128,12 @@ RSpec.describe Airbrake::Config do
|
|
119
128
|
describe "#check_performance_options" do
|
120
129
|
it "returns a promise" do
|
121
130
|
resource = Airbrake::Query.new(method: '', route: '', query: '', timing: 1)
|
122
|
-
expect(
|
131
|
+
expect(config.check_performance_options(resource))
|
123
132
|
.to be_an(Airbrake::Promise)
|
124
133
|
end
|
125
134
|
|
126
135
|
context "when performance stats are disabled" do
|
127
|
-
before {
|
136
|
+
before { config.performance_stats = false }
|
128
137
|
|
129
138
|
let(:resource) do
|
130
139
|
Airbrake::Request.new(
|
@@ -133,7 +142,7 @@ RSpec.describe Airbrake::Config do
|
|
133
142
|
end
|
134
143
|
|
135
144
|
it "returns a rejected promise" do
|
136
|
-
promise =
|
145
|
+
promise = config.check_performance_options(resource)
|
137
146
|
expect(promise.value).to eq(
|
138
147
|
'error' => "The Performance Stats feature is disabled",
|
139
148
|
)
|
@@ -141,14 +150,14 @@ RSpec.describe Airbrake::Config do
|
|
141
150
|
end
|
142
151
|
|
143
152
|
context "when query stats are disabled" do
|
144
|
-
before {
|
153
|
+
before { config.query_stats = false }
|
145
154
|
|
146
155
|
let(:resource) do
|
147
156
|
Airbrake::Query.new(method: 'GET', route: '/foo', query: '', timing: 1)
|
148
157
|
end
|
149
158
|
|
150
159
|
it "returns a rejected promise" do
|
151
|
-
promise =
|
160
|
+
promise = config.check_performance_options(resource)
|
152
161
|
expect(promise.value).to eq(
|
153
162
|
'error' => "The Query Stats feature is disabled",
|
154
163
|
)
|
@@ -156,14 +165,14 @@ RSpec.describe Airbrake::Config do
|
|
156
165
|
end
|
157
166
|
|
158
167
|
context "when job stats are disabled" do
|
159
|
-
before {
|
168
|
+
before { config.job_stats = false }
|
160
169
|
|
161
170
|
let(:resource) do
|
162
171
|
Airbrake::Queue.new(queue: 'foo_queue', error_count: 0, timing: 1)
|
163
172
|
end
|
164
173
|
|
165
174
|
it "returns a rejected promise" do
|
166
|
-
promise =
|
175
|
+
promise = config.check_performance_options(resource)
|
167
176
|
expect(promise.value).to eq(
|
168
177
|
'error' => "The Job Stats feature is disabled",
|
169
178
|
)
|
@@ -173,7 +182,7 @@ RSpec.describe Airbrake::Config do
|
|
173
182
|
|
174
183
|
describe "#logger" do
|
175
184
|
it "sets logger level to Logger::WARN" do
|
176
|
-
expect(
|
185
|
+
expect(config.logger.level).to eq(Logger::WARN)
|
177
186
|
end
|
178
187
|
end
|
179
188
|
end
|