airbrake-ruby 3.2.6 → 4.0.0
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 +31 -138
- data/lib/airbrake-ruby/async_sender.rb +20 -8
- data/lib/airbrake-ruby/backtrace.rb +15 -13
- data/lib/airbrake-ruby/code_hunk.rb +2 -4
- data/lib/airbrake-ruby/config.rb +8 -38
- data/lib/airbrake-ruby/deploy_notifier.rb +4 -17
- data/lib/airbrake-ruby/filters/exception_attributes_filter.rb +5 -4
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +6 -4
- data/lib/airbrake-ruby/filters/keys_blacklist.rb +0 -1
- data/lib/airbrake-ruby/filters/keys_filter.rb +4 -4
- data/lib/airbrake-ruby/filters/keys_whitelist.rb +0 -1
- data/lib/airbrake-ruby/loggable.rb +31 -0
- data/lib/airbrake-ruby/nested_exception.rb +2 -3
- data/lib/airbrake-ruby/notice.rb +6 -6
- data/lib/airbrake-ruby/notice_notifier.rb +11 -47
- data/lib/airbrake-ruby/performance_notifier.rb +6 -18
- data/lib/airbrake-ruby/response.rb +5 -2
- data/lib/airbrake-ruby/sync_sender.rb +8 -6
- data/lib/airbrake-ruby/version.rb +1 -1
- data/spec/airbrake_spec.rb +1 -143
- data/spec/async_sender_spec.rb +83 -90
- data/spec/backtrace_spec.rb +36 -47
- data/spec/code_hunk_spec.rb +12 -15
- data/spec/config_spec.rb +79 -96
- data/spec/deploy_notifier_spec.rb +3 -7
- data/spec/filter_chain_spec.rb +1 -3
- data/spec/filters/context_filter_spec.rb +1 -3
- data/spec/filters/dependency_filter_spec.rb +1 -3
- data/spec/filters/exception_attributes_filter_spec.rb +1 -14
- data/spec/filters/gem_root_filter_spec.rb +1 -4
- data/spec/filters/git_last_checkout_filter_spec.rb +3 -5
- data/spec/filters/git_revision_filter_spec.rb +1 -3
- data/spec/filters/keys_blacklist_spec.rb +14 -25
- data/spec/filters/keys_whitelist_spec.rb +14 -25
- data/spec/filters/root_directory_filter_spec.rb +1 -4
- data/spec/filters/system_exit_filter_spec.rb +2 -2
- data/spec/filters/thread_filter_spec.rb +1 -3
- data/spec/nested_exception_spec.rb +3 -5
- data/spec/notice_notifier_spec.rb +23 -20
- data/spec/notice_notifier_spec/options_spec.rb +20 -25
- data/spec/notice_spec.rb +13 -12
- data/spec/performance_notifier_spec.rb +19 -31
- data/spec/response_spec.rb +23 -17
- data/spec/sync_sender_spec.rb +26 -33
- metadata +2 -1
data/spec/backtrace_spec.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
1
|
RSpec.describe Airbrake::Backtrace do
|
2
|
-
let(:config) do
|
3
|
-
Airbrake::Config.new.tap { |c| c.logger = Logger.new('/dev/null') }
|
4
|
-
end
|
5
|
-
|
6
2
|
describe ".parse" do
|
7
3
|
context "UNIX backtrace" do
|
8
4
|
let(:parsed_backtrace) do
|
@@ -24,9 +20,8 @@ RSpec.describe Airbrake::Backtrace do
|
|
24
20
|
end
|
25
21
|
|
26
22
|
it "returns a properly formatted array of hashes" do
|
27
|
-
expect(
|
28
|
-
|
29
|
-
).to eq(parsed_backtrace)
|
23
|
+
expect(described_class.parse(AirbrakeTestError.new)).
|
24
|
+
to eq(parsed_backtrace)
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
@@ -46,7 +41,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
46
41
|
end
|
47
42
|
|
48
43
|
it "returns a properly formatted array of hashes" do
|
49
|
-
expect(described_class.parse(
|
44
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
@@ -70,9 +65,8 @@ RSpec.describe Airbrake::Backtrace do
|
|
70
65
|
it "returns a properly formatted array of hashes" do
|
71
66
|
allow(described_class).to receive(:java_exception?).and_return(true)
|
72
67
|
|
73
|
-
expect(
|
74
|
-
|
75
|
-
).to eq(backtrace_array)
|
68
|
+
expect(described_class.parse(JavaAirbrakeTestError.new)).
|
69
|
+
to eq(backtrace_array)
|
76
70
|
end
|
77
71
|
end
|
78
72
|
|
@@ -99,7 +93,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
99
93
|
|
100
94
|
it "returns a properly formatted array of hashes" do
|
101
95
|
allow(described_class).to receive(:java_exception?).and_return(true)
|
102
|
-
expect(described_class.parse(
|
96
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
103
97
|
end
|
104
98
|
end
|
105
99
|
|
@@ -123,7 +117,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
123
117
|
let(:ex) { AirbrakeTestError.new.tap { |e| e.set_backtrace(backtrace) } }
|
124
118
|
|
125
119
|
it "returns a properly formatted array of hashes" do
|
126
|
-
expect(described_class.parse(
|
120
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
127
121
|
end
|
128
122
|
end
|
129
123
|
|
@@ -148,7 +142,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
148
142
|
end
|
149
143
|
|
150
144
|
it "returns a properly formatted array of hashes" do
|
151
|
-
expect(described_class.parse(
|
145
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
152
146
|
end
|
153
147
|
end
|
154
148
|
|
@@ -166,7 +160,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
166
160
|
end
|
167
161
|
|
168
162
|
it "returns a properly formatted array of hashes" do
|
169
|
-
expect(described_class.parse(
|
163
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
170
164
|
end
|
171
165
|
end
|
172
166
|
end
|
@@ -178,18 +172,15 @@ RSpec.describe Airbrake::Backtrace do
|
|
178
172
|
|
179
173
|
it "returns array of hashes where each unknown frame is marked as 'function'" do
|
180
174
|
expect(
|
181
|
-
described_class.parse(
|
175
|
+
described_class.parse(ex)
|
182
176
|
).to eq([file: nil, line: nil, function: 'a b c 1 23 321 .rb'])
|
183
177
|
end
|
184
178
|
|
185
|
-
it "logs
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
to change { out.string }.
|
191
|
-
from('').
|
192
|
-
to(/ERROR -- : can't parse 'a b c 1 23 321 .rb'/)
|
179
|
+
it "logs frames that cannot be parsed" do
|
180
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
181
|
+
/can't parse 'a b c 1 23 321 .rb'/
|
182
|
+
)
|
183
|
+
described_class.parse(ex)
|
193
184
|
end
|
194
185
|
end
|
195
186
|
|
@@ -207,7 +198,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
207
198
|
end
|
208
199
|
|
209
200
|
it "returns a properly formatted array of hashes" do
|
210
|
-
expect(described_class.parse(
|
201
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
211
202
|
end
|
212
203
|
end
|
213
204
|
|
@@ -230,7 +221,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
230
221
|
|
231
222
|
it "returns a properly formatted array of hashes" do
|
232
223
|
stub_const('OCIError', AirbrakeTestError)
|
233
|
-
expect(described_class.parse(
|
224
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
234
225
|
end
|
235
226
|
end
|
236
227
|
|
@@ -263,20 +254,17 @@ RSpec.describe Airbrake::Backtrace do
|
|
263
254
|
|
264
255
|
it "returns a properly formatted array of hashes" do
|
265
256
|
stub_const('ExecJS::RuntimeError', AirbrakeTestError)
|
266
|
-
expect(described_class.parse(
|
257
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
267
258
|
end
|
268
259
|
end
|
269
260
|
|
270
261
|
context "when code hunks are enabled" do
|
271
|
-
|
272
|
-
config = Airbrake::Config.new
|
273
|
-
config.logger = Logger.new('/dev/null')
|
274
|
-
config.code_hunks = true
|
275
|
-
config
|
276
|
-
end
|
262
|
+
before { Airbrake::Config.instance.merge(code_hunks: true) }
|
277
263
|
|
278
264
|
context "and when root_directory is configured" do
|
279
|
-
before
|
265
|
+
before do
|
266
|
+
Airbrake::Config.instance.merge(root_directory: project_root_path(''))
|
267
|
+
end
|
280
268
|
|
281
269
|
let(:parsed_backtrace) do
|
282
270
|
[
|
@@ -315,12 +303,16 @@ RSpec.describe Airbrake::Backtrace do
|
|
315
303
|
project_root_path('vendor/bundle/ignored_file.rb') + ":2:in `ignore_me'"
|
316
304
|
]
|
317
305
|
ex.set_backtrace(backtrace)
|
318
|
-
expect(described_class.parse(
|
306
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
319
307
|
end
|
320
308
|
end
|
321
309
|
|
322
310
|
context "and when root_directory is a Pathname" do
|
323
|
-
before
|
311
|
+
before do
|
312
|
+
Airbrake::Config.instance.merge(
|
313
|
+
root_directory: Pathname.new(project_root_path(''))
|
314
|
+
)
|
315
|
+
end
|
324
316
|
|
325
317
|
let(:parsed_backtrace) do
|
326
318
|
[
|
@@ -344,13 +336,13 @@ RSpec.describe Airbrake::Backtrace do
|
|
344
336
|
it "attaches code to those frames files of which match root_directory" do
|
345
337
|
ex = RuntimeError.new
|
346
338
|
ex.set_backtrace([project_root_path('code.rb') + ":94:in `to_json'"])
|
347
|
-
expect(described_class.parse(
|
339
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
348
340
|
end
|
349
341
|
end
|
350
342
|
|
351
343
|
context "and when root_directory isn't configured" do
|
352
344
|
before do
|
353
|
-
|
345
|
+
Airbrake::Config.instance.merge(root_directory: nil)
|
354
346
|
stub_const('Airbrake::Backtrace::CODE_FRAME_LIMIT', 2)
|
355
347
|
end
|
356
348
|
|
@@ -400,21 +392,18 @@ RSpec.describe Airbrake::Backtrace do
|
|
400
392
|
project_root_path('code.rb') + ":96:in `to_json'"
|
401
393
|
]
|
402
394
|
ex.set_backtrace(backtrace)
|
403
|
-
expect(described_class.parse(
|
395
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
404
396
|
end
|
405
397
|
end
|
406
398
|
end
|
407
399
|
|
408
400
|
context "when code hunks are disabled" do
|
409
|
-
|
410
|
-
config = Airbrake::Config.new
|
411
|
-
config.logger = Logger.new('/dev/null')
|
412
|
-
config.code_hunks = false
|
413
|
-
config
|
414
|
-
end
|
401
|
+
before { Airbrake::Config.instance.merge(code_hunks: false) }
|
415
402
|
|
416
403
|
context "and when root_directory is configured" do
|
417
|
-
before
|
404
|
+
before do
|
405
|
+
Airbrake::Config.instance.merge(root_directory: project_root_path(''))
|
406
|
+
end
|
418
407
|
|
419
408
|
let(:parsed_backtrace) do
|
420
409
|
[
|
@@ -430,7 +419,7 @@ RSpec.describe Airbrake::Backtrace do
|
|
430
419
|
ex = RuntimeError.new
|
431
420
|
backtrace = [project_root_path('code.rb') + ":94:in `to_json'"]
|
432
421
|
ex.set_backtrace(backtrace)
|
433
|
-
expect(described_class.parse(
|
422
|
+
expect(described_class.parse(ex)).to eq(parsed_backtrace)
|
434
423
|
end
|
435
424
|
end
|
436
425
|
end
|
data/spec/code_hunk_spec.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
RSpec.describe Airbrake::CodeHunk do
|
2
|
-
let(:config) { Airbrake::Config.new }
|
3
|
-
|
4
2
|
after do
|
5
3
|
%w[empty_file.rb code.rb banana.rb short_file.rb long_line.txt].each do |f|
|
6
4
|
Airbrake::FileCache[project_root_path(f)] = nil
|
@@ -10,26 +8,26 @@ RSpec.describe Airbrake::CodeHunk do
|
|
10
8
|
describe "#to_h" do
|
11
9
|
context "when file is empty" do
|
12
10
|
subject do
|
13
|
-
described_class.new
|
11
|
+
described_class.new.get(project_root_path('empty_file.rb'), 1)
|
14
12
|
end
|
15
13
|
|
16
14
|
it { is_expected.to eq(1 => '') }
|
17
15
|
end
|
18
16
|
|
19
17
|
context "when line is nil" do
|
20
|
-
subject { described_class.new
|
18
|
+
subject { described_class.new.get(project_root_path('code.rb'), nil) }
|
21
19
|
|
22
20
|
it { is_expected.to be_nil }
|
23
21
|
end
|
24
22
|
|
25
23
|
context "when a file doesn't exist" do
|
26
|
-
subject { described_class.new
|
24
|
+
subject { described_class.new.get(project_root_path('banana.rb'), 1) }
|
27
25
|
|
28
26
|
it { is_expected.to be_nil }
|
29
27
|
end
|
30
28
|
|
31
29
|
context "when a file has less than NLINES lines before start line" do
|
32
|
-
subject { described_class.new
|
30
|
+
subject { described_class.new.get(project_root_path('code.rb'), 1) }
|
33
31
|
|
34
32
|
it do
|
35
33
|
is_expected.to(
|
@@ -45,7 +43,7 @@ RSpec.describe Airbrake::CodeHunk do
|
|
45
43
|
end
|
46
44
|
|
47
45
|
context "when a file has less than NLINES lines after end line" do
|
48
|
-
subject { described_class.new
|
46
|
+
subject { described_class.new.get(project_root_path('code.rb'), 222) }
|
49
47
|
|
50
48
|
it do
|
51
49
|
is_expected.to(
|
@@ -59,7 +57,7 @@ RSpec.describe Airbrake::CodeHunk do
|
|
59
57
|
|
60
58
|
context "when a file has less than NLINES lines before and after" do
|
61
59
|
subject do
|
62
|
-
described_class.new
|
60
|
+
described_class.new.get(project_root_path('short_file.rb'), 2)
|
63
61
|
end
|
64
62
|
|
65
63
|
it do
|
@@ -74,7 +72,7 @@ RSpec.describe Airbrake::CodeHunk do
|
|
74
72
|
end
|
75
73
|
|
76
74
|
context "when a file has enough lines before and after" do
|
77
|
-
subject { described_class.new
|
75
|
+
subject { described_class.new.get(project_root_path('code.rb'), 100) }
|
78
76
|
|
79
77
|
it do
|
80
78
|
is_expected.to(
|
@@ -91,7 +89,7 @@ RSpec.describe Airbrake::CodeHunk do
|
|
91
89
|
|
92
90
|
context "when a line exceeds the length limit" do
|
93
91
|
subject do
|
94
|
-
described_class.new
|
92
|
+
described_class.new.get(project_root_path('long_line.txt'), 1)
|
95
93
|
end
|
96
94
|
|
97
95
|
it "strips the line" do
|
@@ -105,13 +103,12 @@ RSpec.describe Airbrake::CodeHunk do
|
|
105
103
|
end
|
106
104
|
|
107
105
|
it "logs error and returns nil" do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
expect(
|
106
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
107
|
+
/can't read code hunk.+Permission denied/
|
108
|
+
)
|
109
|
+
expect(subject.get(project_root_path('code.rb'), 1)).to(
|
112
110
|
eq(1 => '')
|
113
111
|
)
|
114
|
-
expect(out.string).to match(/can't read code hunk.+Permission denied/)
|
115
112
|
end
|
116
113
|
end
|
117
114
|
end
|
data/spec/config_spec.rb
CHANGED
@@ -1,43 +1,41 @@
|
|
1
1
|
RSpec.describe Airbrake::Config do
|
2
|
-
let(:config) { described_class.new }
|
3
|
-
|
4
2
|
describe "#new" do
|
5
3
|
describe "options" do
|
6
4
|
it "doesn't set the default project_id" do
|
7
|
-
expect(
|
5
|
+
expect(subject.project_id).to be_nil
|
8
6
|
end
|
9
7
|
|
10
8
|
it "doesn't set the default project_key" do
|
11
|
-
expect(
|
9
|
+
expect(subject.project_key).to be_nil
|
12
10
|
end
|
13
11
|
|
14
12
|
it "doesn't set the default proxy" do
|
15
|
-
expect(
|
13
|
+
expect(subject.proxy).to be_empty
|
16
14
|
end
|
17
15
|
|
18
16
|
it "sets the default logger" do
|
19
|
-
expect(
|
17
|
+
expect(subject.logger).to be_a Logger
|
20
18
|
end
|
21
19
|
|
22
20
|
it "doesn't set the default app_version" do
|
23
|
-
expect(
|
21
|
+
expect(subject.app_version).to be_nil
|
24
22
|
end
|
25
23
|
|
26
24
|
it "sets the default versions" do
|
27
|
-
expect(
|
25
|
+
expect(subject.versions).to be_empty
|
28
26
|
end
|
29
27
|
|
30
28
|
it "sets the default host" do
|
31
|
-
expect(
|
29
|
+
expect(subject.host).to eq('https://api.airbrake.io')
|
32
30
|
end
|
33
31
|
|
34
32
|
it "sets the default endpoint" do
|
35
|
-
expect(
|
33
|
+
expect(subject.endpoint).not_to be_nil
|
36
34
|
end
|
37
35
|
|
38
36
|
it "creates a new Config and merges it with the user config" do
|
39
|
-
|
40
|
-
expect(
|
37
|
+
config = described_class.new(logger: StringIO.new)
|
38
|
+
expect(config.logger).to be_a(StringIO)
|
41
39
|
end
|
42
40
|
|
43
41
|
it "raises error on unknown config options" do
|
@@ -46,57 +44,43 @@ RSpec.describe Airbrake::Config do
|
|
46
44
|
end
|
47
45
|
|
48
46
|
it "sets the default number of workers" do
|
49
|
-
expect(
|
47
|
+
expect(subject.workers).to eq(1)
|
50
48
|
end
|
51
49
|
|
52
50
|
it "sets the default number of queue size" do
|
53
|
-
expect(
|
51
|
+
expect(subject.queue_size).to eq(100)
|
54
52
|
end
|
55
53
|
|
56
54
|
it "sets the default root_directory" do
|
57
|
-
expect(
|
55
|
+
expect(subject.root_directory).to eq Bundler.root.realpath.to_s
|
58
56
|
end
|
59
57
|
|
60
58
|
it "doesn't set the default environment" do
|
61
|
-
expect(
|
59
|
+
expect(subject.environment).to be_nil
|
62
60
|
end
|
63
61
|
|
64
62
|
it "doesn't set default notify_environments" do
|
65
|
-
expect(
|
63
|
+
expect(subject.ignore_environments).to be_empty
|
66
64
|
end
|
67
65
|
|
68
66
|
it "doesn't set default timeout" do
|
69
|
-
expect(
|
67
|
+
expect(subject.timeout).to be_nil
|
70
68
|
end
|
71
69
|
|
72
70
|
it "doesn't set default blacklist" do
|
73
|
-
expect(
|
71
|
+
expect(subject.blacklist_keys).to be_empty
|
74
72
|
end
|
75
73
|
|
76
74
|
it "doesn't set default whitelist" do
|
77
|
-
expect(
|
78
|
-
end
|
79
|
-
|
80
|
-
it "disables route stats by default (deprecated)" do
|
81
|
-
out = StringIO.new
|
82
|
-
config.logger = Logger.new(out)
|
83
|
-
expect(config.route_stats).to be_falsey
|
84
|
-
expect(out.string).to match(/'route_stats'.+is deprecated/)
|
75
|
+
expect(subject.whitelist_keys).to be_empty
|
85
76
|
end
|
86
77
|
|
87
78
|
it "disables performance stats by default" do
|
88
|
-
expect(
|
89
|
-
end
|
90
|
-
|
91
|
-
it "sets the default route_stats_flush_period (deprecated)" do
|
92
|
-
out = StringIO.new
|
93
|
-
config.logger = Logger.new(out)
|
94
|
-
expect(config.route_stats_flush_period).to eq(15)
|
95
|
-
expect(out.string).to match(/'route_stats_flush_period'.+is deprecated/)
|
79
|
+
expect(subject.performance_stats).to be_falsey
|
96
80
|
end
|
97
81
|
|
98
82
|
it "sets the default performance_stats_flush_period" do
|
99
|
-
expect(
|
83
|
+
expect(subject.performance_stats_flush_period).to eq(15)
|
100
84
|
end
|
101
85
|
end
|
102
86
|
end
|
@@ -104,18 +88,20 @@ RSpec.describe Airbrake::Config do
|
|
104
88
|
describe "#valid?" do
|
105
89
|
context "when project_id is nil" do
|
106
90
|
it "returns false" do
|
107
|
-
config
|
108
|
-
|
109
|
-
|
91
|
+
config = described_class.new(
|
92
|
+
project_id: nil,
|
93
|
+
project_key: '123'
|
94
|
+
)
|
110
95
|
expect(config).not_to be_valid
|
111
96
|
end
|
112
97
|
end
|
113
98
|
|
114
99
|
context "when project_key is nil" do
|
115
100
|
it "returns false" do
|
116
|
-
config
|
117
|
-
|
118
|
-
|
101
|
+
config = described_class.new(
|
102
|
+
project_id: 123,
|
103
|
+
project_key: nil
|
104
|
+
)
|
119
105
|
expect(config).not_to be_valid
|
120
106
|
end
|
121
107
|
end
|
@@ -123,22 +109,24 @@ RSpec.describe Airbrake::Config do
|
|
123
109
|
context "when the current environment is ignored" do
|
124
110
|
context "and when the notifier misconfigures configure project_key & project_id" do
|
125
111
|
it "returns true" do
|
126
|
-
config
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
112
|
+
config = described_class.new(
|
113
|
+
project_id: Object.new,
|
114
|
+
project_key: Object.new,
|
115
|
+
environment: :bingo,
|
116
|
+
ignore_environments: [:bingo]
|
117
|
+
)
|
131
118
|
expect(config).to be_valid
|
132
119
|
end
|
133
120
|
end
|
134
121
|
|
135
122
|
context "and when the notifier configures project_key & project_id" do
|
136
123
|
it "returns true" do
|
137
|
-
config
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
124
|
+
config = described_class.new(
|
125
|
+
project_id: 123,
|
126
|
+
project_key: '321',
|
127
|
+
environment: :bingo,
|
128
|
+
ignore_environments: [:bingo]
|
129
|
+
)
|
142
130
|
expect(config).to be_valid
|
143
131
|
end
|
144
132
|
end
|
@@ -146,52 +134,54 @@ RSpec.describe Airbrake::Config do
|
|
146
134
|
|
147
135
|
context "when the project_id value is not a number" do
|
148
136
|
it "returns false" do
|
149
|
-
config
|
150
|
-
|
151
|
-
|
137
|
+
config = described_class.new(
|
138
|
+
project_id: 'bingo',
|
139
|
+
project_key: '321'
|
140
|
+
)
|
152
141
|
expect(config).not_to be_valid
|
153
142
|
end
|
154
143
|
end
|
155
144
|
|
156
145
|
context "when the project_id value is a String number" do
|
157
146
|
it "returns true" do
|
158
|
-
config
|
159
|
-
|
160
|
-
|
147
|
+
config = described_class.new(
|
148
|
+
project_id: '123',
|
149
|
+
project_key: '321'
|
150
|
+
)
|
161
151
|
expect(config).to be_valid
|
162
152
|
end
|
163
153
|
end
|
164
154
|
|
165
155
|
context "when the project_key value is not a String" do
|
166
156
|
it "returns false" do
|
167
|
-
config
|
168
|
-
|
169
|
-
|
157
|
+
config = described_class.new(
|
158
|
+
project_id: 123,
|
159
|
+
project_key: 321
|
160
|
+
)
|
170
161
|
expect(config).not_to be_valid
|
171
162
|
end
|
172
163
|
end
|
173
164
|
|
174
165
|
context "when the project_key value is an empty String" do
|
175
166
|
it "returns false" do
|
176
|
-
config
|
177
|
-
|
178
|
-
|
167
|
+
config = described_class.new(
|
168
|
+
project_id: 123,
|
169
|
+
project_key: ''
|
170
|
+
)
|
179
171
|
expect(config).not_to be_valid
|
180
172
|
end
|
181
173
|
end
|
182
174
|
|
183
175
|
context "when the environment value is not a String" do
|
184
|
-
let(:out) { StringIO.new }
|
185
|
-
let(:config) { described_class.new(logger: Logger.new(out)) }
|
186
|
-
|
187
176
|
before do
|
188
|
-
config.project_id = 123
|
189
|
-
config.project_key = '321'
|
190
|
-
|
191
|
-
config.environment = ['bingo']
|
192
177
|
end
|
193
178
|
|
194
179
|
it "returns false" do
|
180
|
+
config = described_class.new(
|
181
|
+
project_id: 123,
|
182
|
+
project_key: '321',
|
183
|
+
environment: ['bingo']
|
184
|
+
)
|
195
185
|
expect(config).not_to be_valid
|
196
186
|
end
|
197
187
|
end
|
@@ -199,32 +189,26 @@ RSpec.describe Airbrake::Config do
|
|
199
189
|
|
200
190
|
describe "#ignored_environment?" do
|
201
191
|
describe "warnings" do
|
202
|
-
let(:out) { StringIO.new }
|
203
|
-
let(:config) { described_class.new(logger: Logger.new(out)) }
|
204
|
-
|
205
192
|
context "when 'ignore_environments' is set and 'environment' isn't" do
|
206
193
|
it "prints a warning" do
|
207
|
-
config.ignore_environments
|
194
|
+
config = described_class.new(ignore_environments: [:bingo])
|
208
195
|
|
196
|
+
expect(config.logger).to receive(:warn).with(
|
197
|
+
/'ignore_environments' has no effect/
|
198
|
+
)
|
209
199
|
expect(config.ignored_environment?).to be_falsey
|
210
|
-
expect(out.string).to match(/ignore_environments' has no effect/)
|
211
200
|
end
|
212
201
|
end
|
213
202
|
|
214
203
|
context "when 'ignore_environments' is set along with 'environment'" do
|
215
204
|
it "doesn't print a warning" do
|
216
|
-
config
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
expect(out.string).to be_empty
|
221
|
-
end
|
222
|
-
end
|
205
|
+
config = described_class.new(
|
206
|
+
environment: :bango,
|
207
|
+
ignore_environments: [:bingo]
|
208
|
+
)
|
223
209
|
|
224
|
-
|
225
|
-
it "doesn't print a warning" do
|
210
|
+
expect(config.logger).not_to receive(:warn)
|
226
211
|
expect(config.ignored_environment?).to be_falsey
|
227
|
-
expect(out.string).to be_empty
|
228
212
|
end
|
229
213
|
end
|
230
214
|
end
|
@@ -233,9 +217,10 @@ RSpec.describe Airbrake::Config do
|
|
233
217
|
context "when 'environment' is a String" do
|
234
218
|
context "and when 'ignore_environments' contains Symbols" do
|
235
219
|
it "returns true" do
|
236
|
-
config
|
237
|
-
|
238
|
-
|
220
|
+
config = described_class.new(
|
221
|
+
environment: 'bango',
|
222
|
+
ignore_environments: [:bango]
|
223
|
+
)
|
239
224
|
expect(config.ignored_environment?).to be_truthy
|
240
225
|
end
|
241
226
|
end
|
@@ -244,9 +229,10 @@ RSpec.describe Airbrake::Config do
|
|
244
229
|
context "when 'environment' is a Symbol" do
|
245
230
|
context "and when 'ignore_environments' contains Strings" do
|
246
231
|
it "returns true" do
|
247
|
-
config
|
248
|
-
|
249
|
-
|
232
|
+
config = described_class.new(
|
233
|
+
environment: :bango,
|
234
|
+
ignore_environments: %w[bango]
|
235
|
+
)
|
250
236
|
expect(config.ignored_environment?).to be_truthy
|
251
237
|
end
|
252
238
|
end
|
@@ -256,10 +242,7 @@ RSpec.describe Airbrake::Config do
|
|
256
242
|
|
257
243
|
describe "#endpoint" do
|
258
244
|
context "when host is configured with a URL with a slug" do
|
259
|
-
|
260
|
-
config.project_id = 1
|
261
|
-
config.project_key = '2'
|
262
|
-
end
|
245
|
+
let(:config) { described_class.new(project_id: 1, project_key: '2') }
|
263
246
|
|
264
247
|
context "and with a trailing slash" do
|
265
248
|
it "sets the endpoint with the slug" do
|