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
@@ -11,27 +11,23 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
11
11
|
"https://api.airbrake.io/api/v3/projects/#{project_id}/notices"
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:user_params) do
|
15
|
-
{ project_id: project_id,
|
16
|
-
project_key: project_key,
|
17
|
-
logger: Logger.new(StringIO.new) }
|
18
|
-
end
|
19
|
-
|
20
14
|
let(:params) { {} }
|
21
15
|
let(:ex) { AirbrakeTestError.new }
|
22
|
-
let(:config) { Airbrake::Config.new(user_params.merge(params)) }
|
23
|
-
|
24
|
-
subject { described_class.new(config) }
|
25
16
|
|
26
17
|
before do
|
27
18
|
stub_request(:post, endpoint).to_return(status: 201, body: '{}')
|
19
|
+
|
20
|
+
Airbrake::Config.instance = Airbrake::Config.new(
|
21
|
+
project_id: project_id,
|
22
|
+
project_key: project_key
|
23
|
+
)
|
28
24
|
end
|
29
25
|
|
30
26
|
describe "options" do
|
31
27
|
describe ":host" do
|
32
28
|
context "when custom" do
|
33
29
|
shared_examples 'endpoint' do |host, endpoint, title|
|
34
|
-
|
30
|
+
before { Airbrake::Config.instance.merge(host: host) }
|
35
31
|
|
36
32
|
example(title) do
|
37
33
|
stub_request(:post, endpoint).to_return(status: 201, body: '{}')
|
@@ -70,11 +66,12 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
70
66
|
end
|
71
67
|
|
72
68
|
describe ":root_directory" do
|
73
|
-
|
69
|
+
before do
|
70
|
+
Airbrake::Config.instance.merge(root_directory: '/home/kyrylo/code')
|
71
|
+
end
|
74
72
|
|
75
73
|
it "filters out frames" do
|
76
|
-
|
77
|
-
airbrake.notify_sync(ex)
|
74
|
+
subject.notify_sync(ex)
|
78
75
|
|
79
76
|
expect(
|
80
77
|
a_request(:post, endpoint).
|
@@ -84,7 +81,7 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
84
81
|
|
85
82
|
context "when present and is a" do
|
86
83
|
shared_examples 'root directory' do |dir|
|
87
|
-
|
84
|
+
before { Airbrake::Config.instance.merge(root_directory: dir) }
|
88
85
|
|
89
86
|
it "being included into the notice's payload" do
|
90
87
|
subject.notify_sync(ex)
|
@@ -123,14 +120,12 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
123
120
|
password: 'password' }
|
124
121
|
end
|
125
122
|
|
126
|
-
|
127
|
-
|
123
|
+
before do
|
124
|
+
Airbrake::Config.instance.merge(
|
128
125
|
proxy: proxy_params,
|
129
126
|
host: "http://localhost:#{proxy.config[:Port]}"
|
130
|
-
|
131
|
-
end
|
127
|
+
)
|
132
128
|
|
133
|
-
before do
|
134
129
|
proxy.mount_proc '/' do |req, res|
|
135
130
|
requests << req
|
136
131
|
res.status = 201
|
@@ -165,7 +160,7 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
165
160
|
|
166
161
|
describe ":environment" do
|
167
162
|
context "when present" do
|
168
|
-
|
163
|
+
before { Airbrake::Config.instance.merge(environment: :production) }
|
169
164
|
|
170
165
|
it "being included into the notice's payload" do
|
171
166
|
subject.notify_sync(ex)
|
@@ -179,7 +174,7 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
179
174
|
|
180
175
|
describe ":ignore_environments" do
|
181
176
|
shared_examples 'sent notice' do |params|
|
182
|
-
|
177
|
+
before { Airbrake::Config.instance.merge(params) }
|
183
178
|
|
184
179
|
it "sends a notice" do
|
185
180
|
subject.notify_sync(ex)
|
@@ -188,7 +183,7 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
188
183
|
end
|
189
184
|
|
190
185
|
shared_examples 'ignored notice' do |params|
|
191
|
-
|
186
|
+
before { Airbrake::Config.instance.merge(params) }
|
192
187
|
|
193
188
|
it "ignores exceptions occurring in envs that were not configured" do
|
194
189
|
subject.notify_sync(ex)
|
@@ -245,11 +240,11 @@ RSpec.describe Airbrake::NoticeNotifier do
|
|
245
240
|
# Fixes https://github.com/airbrake/airbrake-ruby/issues/276
|
246
241
|
context "when specified along with :whitelist_keys" do
|
247
242
|
context "and when context payload is present" do
|
248
|
-
|
249
|
-
|
243
|
+
before do
|
244
|
+
Airbrake::Config.instance.merge(
|
250
245
|
blacklist_keys: %i[password password_confirmation],
|
251
246
|
whitelist_keys: [:email, /user/i, 'account_id']
|
252
|
-
|
247
|
+
)
|
253
248
|
end
|
254
249
|
|
255
250
|
it "sends a notice" do
|
data/spec/notice_spec.rb
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
RSpec.describe Airbrake::Notice do
|
2
|
-
let(:notice)
|
3
|
-
described_class.new(Airbrake::Config.new, AirbrakeTestError.new, bingo: '1')
|
4
|
-
end
|
2
|
+
let(:notice) { described_class.new(AirbrakeTestError.new, bingo: '1') }
|
5
3
|
|
6
4
|
describe "#to_json" do
|
7
5
|
context "app_version" do
|
8
6
|
context "when missing" do
|
7
|
+
before { Airbrake::Config.instance.merge(app_version: nil) }
|
8
|
+
|
9
9
|
it "doesn't include app_version" do
|
10
10
|
expect(notice.to_json).not_to match(/"context":{"version":"1.2.3"/)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when present" do
|
15
|
-
let(:
|
16
|
-
Airbrake::Config.new(app_version: '1.2.3', root_directory: '/one/two')
|
17
|
-
end
|
15
|
+
let(:notice) { described_class.new(AirbrakeTestError.new) }
|
18
16
|
|
19
|
-
|
17
|
+
before do
|
18
|
+
Airbrake::Config.instance.merge(
|
19
|
+
app_version: "1.2.3",
|
20
|
+
root_directory: "/one/two"
|
21
|
+
)
|
22
|
+
end
|
20
23
|
|
21
24
|
it "includes app_version" do
|
22
25
|
expect(notice.to_json).to match(/"context":{"version":"1.2.3"/)
|
@@ -54,7 +57,7 @@ RSpec.describe Airbrake::Notice do
|
|
54
57
|
size.times { backtrace << "bin/rails:3:in `<main>'" }
|
55
58
|
ex.set_backtrace(backtrace)
|
56
59
|
|
57
|
-
notice = described_class.new(
|
60
|
+
notice = described_class.new(ex)
|
58
61
|
|
59
62
|
expect(notice.to_json.bytesize).to be < 64000
|
60
63
|
end
|
@@ -94,9 +97,7 @@ RSpec.describe Airbrake::Notice do
|
|
94
97
|
10.times { backtrace << "bin/rails:3:in `<#{bad_string}>'" }
|
95
98
|
ex.set_backtrace(backtrace)
|
96
99
|
|
97
|
-
|
98
|
-
notice = described_class.new(config, ex)
|
99
|
-
|
100
|
+
notice = described_class.new(ex)
|
100
101
|
expect(notice.to_json).to be_nil
|
101
102
|
end
|
102
103
|
end
|
@@ -105,7 +106,7 @@ RSpec.describe Airbrake::Notice do
|
|
105
106
|
let(:klass) { Class.new {} }
|
106
107
|
let(:ex) { AirbrakeTestError.new }
|
107
108
|
let(:params) { { bingo: [Object.new, klass.new] } }
|
108
|
-
let(:notice) { described_class.new(
|
109
|
+
let(:notice) { described_class.new(ex, params) }
|
109
110
|
|
110
111
|
before do
|
111
112
|
backtrace = []
|
@@ -2,8 +2,11 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
2
2
|
let(:routes) { 'https://api.airbrake.io/api/v5/projects/1/routes-stats' }
|
3
3
|
let(:queries) { 'https://api.airbrake.io/api/v5/projects/1/queries-stats' }
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
before do
|
6
|
+
stub_request(:put, routes).to_return(status: 200, body: '')
|
7
|
+
stub_request(:put, queries).to_return(status: 200, body: '')
|
8
|
+
|
9
|
+
Airbrake::Config.instance = Airbrake::Config.new(
|
7
10
|
project_id: 1,
|
8
11
|
project_key: 'banana',
|
9
12
|
performance_stats: true,
|
@@ -11,13 +14,6 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
11
14
|
)
|
12
15
|
end
|
13
16
|
|
14
|
-
subject { described_class.new(config) }
|
15
|
-
|
16
|
-
before do
|
17
|
-
stub_request(:put, routes).to_return(status: 200, body: '')
|
18
|
-
stub_request(:put, queries).to_return(status: 200, body: '')
|
19
|
-
end
|
20
|
-
|
21
17
|
describe "#notify" do
|
22
18
|
it "sends full query" do
|
23
19
|
subject.notify(
|
@@ -195,16 +191,14 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
195
191
|
end
|
196
192
|
|
197
193
|
it "doesn't send route stats when performance stats are disabled" do
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
)
|
202
|
-
)
|
203
|
-
promise = notifier.notify(
|
194
|
+
Airbrake::Config.instance.merge(performance_stats: false)
|
195
|
+
|
196
|
+
promise = subject.notify(
|
204
197
|
Airbrake::Request.new(
|
205
198
|
method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
|
206
199
|
)
|
207
200
|
)
|
201
|
+
|
208
202
|
expect(a_request(:put, routes)).not_to have_been_made
|
209
203
|
expect(promise.value).to eq(
|
210
204
|
'error' => "The Performance Stats feature is disabled"
|
@@ -212,28 +206,24 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
212
206
|
end
|
213
207
|
|
214
208
|
it "doesn't send route stats when current environment is ignored" do
|
215
|
-
|
216
|
-
|
217
|
-
environment: 'test', ignore_environments: %w[test]
|
218
|
-
)
|
209
|
+
Airbrake::Config.instance.merge(
|
210
|
+
performance_stats: true, environment: 'test', ignore_environments: %w[test]
|
219
211
|
)
|
220
|
-
|
212
|
+
|
213
|
+
promise = subject.notify(
|
221
214
|
Airbrake::Request.new(
|
222
215
|
method: 'GET', route: '/foo', status_code: 200, start_time: Time.new
|
223
216
|
)
|
224
217
|
)
|
218
|
+
|
225
219
|
expect(a_request(:put, routes)).not_to have_been_made
|
226
220
|
expect(promise.value).to eq('error' => "The 'test' environment is ignored")
|
227
221
|
end
|
228
222
|
|
229
223
|
it "sends environment when it's specified" do
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
environment: 'test'
|
234
|
-
)
|
235
|
-
)
|
236
|
-
notifier.notify(
|
224
|
+
Airbrake::Config.instance.merge(performance_stats: true, environment: 'test')
|
225
|
+
|
226
|
+
subject.notify(
|
237
227
|
Airbrake::Request.new(
|
238
228
|
method: 'POST',
|
239
229
|
route: '/foo',
|
@@ -251,16 +241,14 @@ RSpec.describe Airbrake::PerformanceNotifier do
|
|
251
241
|
describe "payload grouping" do
|
252
242
|
let(:flush_period) { 0.5 }
|
253
243
|
|
254
|
-
|
255
|
-
Airbrake::Config.
|
244
|
+
it "groups payload by performance name and sends it separately" do
|
245
|
+
Airbrake::Config.instance.merge(
|
256
246
|
project_id: 1,
|
257
247
|
project_key: 'banana',
|
258
248
|
performance_stats: true,
|
259
249
|
performance_stats_flush_period: flush_period
|
260
250
|
)
|
261
|
-
end
|
262
251
|
|
263
|
-
it "groups payload by performance name and sends it separately" do
|
264
252
|
subject.notify(
|
265
253
|
Airbrake::Request.new(
|
266
254
|
method: 'GET',
|
data/spec/response_spec.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
RSpec.describe Airbrake::Response do
|
2
2
|
describe ".parse" do
|
3
|
-
let(:out) { StringIO.new }
|
4
|
-
let(:logger) { Logger.new(out) }
|
5
|
-
|
6
3
|
[200, 201, 204].each do |code|
|
7
4
|
context "when response code is #{code}" do
|
8
5
|
it "logs response body" do
|
9
|
-
|
10
|
-
|
6
|
+
expect(Airbrake::Loggable.instance).to receive(:debug).with(
|
7
|
+
/Airbrake::Response \(#{code}\): {}/
|
8
|
+
)
|
9
|
+
described_class.parse(OpenStruct.new(code: code, body: '{}'))
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -15,26 +14,31 @@ RSpec.describe Airbrake::Response do
|
|
15
14
|
[400, 401, 403, 420].each do |code|
|
16
15
|
context "when response code is #{code}" do
|
17
16
|
it "logs response message" do
|
17
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
18
|
+
/Airbrake: foo/
|
19
|
+
)
|
18
20
|
described_class.parse(
|
19
|
-
OpenStruct.new(code: code, body: '{"message":"foo"}')
|
21
|
+
OpenStruct.new(code: code, body: '{"message":"foo"}')
|
20
22
|
)
|
21
|
-
expect(out.string).to match(/Airbrake: foo/)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
27
|
context "when response code is 429" do
|
27
28
|
let(:response) { OpenStruct.new(code: 429, body: '{"message":"rate limited"}') }
|
29
|
+
|
28
30
|
it "logs response message" do
|
29
|
-
|
30
|
-
|
31
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
32
|
+
/Airbrake: rate limited/
|
33
|
+
)
|
34
|
+
described_class.parse(response)
|
31
35
|
end
|
32
36
|
|
33
37
|
it "returns an error response" do
|
34
38
|
time = Time.now
|
35
39
|
allow(Time).to receive(:now).and_return(time)
|
36
40
|
|
37
|
-
resp = described_class.parse(response
|
41
|
+
resp = described_class.parse(response)
|
38
42
|
expect(resp).to include(
|
39
43
|
'error' => '**Airbrake: rate limited',
|
40
44
|
'rate_limit_reset' => time
|
@@ -46,18 +50,20 @@ RSpec.describe Airbrake::Response do
|
|
46
50
|
let(:response) { OpenStruct.new(code: 500, body: 'foo') }
|
47
51
|
|
48
52
|
it "logs response body" do
|
49
|
-
|
50
|
-
|
53
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
54
|
+
/Airbrake: unexpected code \(500\)\. Body: foo/
|
55
|
+
)
|
56
|
+
described_class.parse(response)
|
51
57
|
end
|
52
58
|
|
53
59
|
it "returns an error response" do
|
54
|
-
resp = described_class.parse(response
|
60
|
+
resp = described_class.parse(response)
|
55
61
|
expect(resp).to eq('error' => 'foo')
|
56
62
|
end
|
57
63
|
|
58
64
|
it "truncates body" do
|
59
65
|
response.body *= 1000
|
60
|
-
resp = described_class.parse(response
|
66
|
+
resp = described_class.parse(response)
|
61
67
|
expect(resp).to eq('error' => ('foo' * 33) + 'fo...')
|
62
68
|
end
|
63
69
|
end
|
@@ -66,14 +72,14 @@ RSpec.describe Airbrake::Response do
|
|
66
72
|
let(:response) { OpenStruct.new(code: 201, body: 'foo') }
|
67
73
|
|
68
74
|
it "logs response body" do
|
69
|
-
|
70
|
-
expect(out.string).to match(
|
75
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
71
76
|
/Airbrake: error while parsing body \(.*unexpected token.*\)\. Body: foo/
|
72
77
|
)
|
78
|
+
described_class.parse(response)
|
73
79
|
end
|
74
80
|
|
75
81
|
it "returns an error message" do
|
76
|
-
expect(described_class.parse(response
|
82
|
+
expect(described_class.parse(response)['error']).to match(
|
77
83
|
/\A#<JSON::ParserError.+>/
|
78
84
|
)
|
79
85
|
end
|
data/spec/sync_sender_spec.rb
CHANGED
@@ -1,34 +1,20 @@
|
|
1
1
|
RSpec.describe Airbrake::SyncSender do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
https = sender.__send__(:build_https, config.endpoint)
|
7
|
-
expect(https.open_timeout).to eq(10)
|
8
|
-
expect(https.read_timeout).to eq(10)
|
9
|
-
end
|
2
|
+
before do
|
3
|
+
Airbrake::Config.instance = Airbrake::Config.new(
|
4
|
+
project_id: 1, project_key: 'banana'
|
5
|
+
)
|
10
6
|
end
|
11
7
|
|
12
8
|
describe "#send" do
|
13
9
|
let(:promise) { Airbrake::Promise.new }
|
14
|
-
let(:stdout) { StringIO.new }
|
15
|
-
|
16
|
-
let(:config) do
|
17
|
-
Airbrake::Config.new(
|
18
|
-
project_id: 1,
|
19
|
-
project_key: 'banana',
|
20
|
-
logger: Logger.new(stdout)
|
21
|
-
)
|
22
|
-
end
|
23
10
|
|
24
|
-
let(:
|
25
|
-
let(:notice) { Airbrake::Notice.new(config, AirbrakeTestError.new) }
|
11
|
+
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
26
12
|
let(:endpoint) { 'https://api.airbrake.io/api/v3/projects/1/notices' }
|
27
13
|
|
28
14
|
before { stub_request(:post, endpoint).to_return(body: '{}') }
|
29
15
|
|
30
16
|
it "sets the Content-Type header to JSON" do
|
31
|
-
|
17
|
+
subject.send({}, promise)
|
32
18
|
expect(
|
33
19
|
a_request(:post, endpoint).with(
|
34
20
|
headers: { 'Content-Type' => 'application/json' }
|
@@ -37,7 +23,7 @@ RSpec.describe Airbrake::SyncSender do
|
|
37
23
|
end
|
38
24
|
|
39
25
|
it "sets the User-Agent header to the notifier slug" do
|
40
|
-
|
26
|
+
subject.send({}, promise)
|
41
27
|
expect(
|
42
28
|
a_request(:post, endpoint).with(
|
43
29
|
headers: {
|
@@ -48,7 +34,7 @@ RSpec.describe Airbrake::SyncSender do
|
|
48
34
|
end
|
49
35
|
|
50
36
|
it "sets the Authorization header to the project key" do
|
51
|
-
|
37
|
+
subject.send({}, promise)
|
52
38
|
expect(
|
53
39
|
a_request(:post, endpoint).with(
|
54
40
|
headers: { 'Authorization' => 'Bearer banana' }
|
@@ -58,11 +44,13 @@ RSpec.describe Airbrake::SyncSender do
|
|
58
44
|
|
59
45
|
it "catches exceptions raised while sending" do
|
60
46
|
https = double("foo")
|
61
|
-
allow(
|
47
|
+
allow(subject).to receive(:build_https).and_return(https)
|
62
48
|
allow(https).to receive(:request).and_raise(StandardError.new('foo'))
|
63
|
-
expect(
|
49
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
50
|
+
/HTTP error: foo/
|
51
|
+
)
|
52
|
+
expect(subject.send({}, promise)).to be_an(Airbrake::Promise)
|
64
53
|
expect(promise.value).to eq('error' => '**Airbrake: HTTP error: foo')
|
65
|
-
expect(stdout.string).to match(/ERROR -- : .+ HTTP error: foo/)
|
66
54
|
end
|
67
55
|
|
68
56
|
context "when request body is nil" do
|
@@ -78,12 +66,17 @@ RSpec.describe Airbrake::SyncSender do
|
|
78
66
|
10.times { backtrace << "bin/rails:3:in `<#{bad_string}>'" }
|
79
67
|
ex.set_backtrace(backtrace)
|
80
68
|
|
81
|
-
notice = Airbrake::Notice.new(
|
69
|
+
notice = Airbrake::Notice.new(ex)
|
82
70
|
|
83
|
-
expect(
|
71
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
72
|
+
/data was not sent/
|
73
|
+
)
|
74
|
+
expect(Airbrake::Loggable.instance).to receive(:error).with(
|
75
|
+
/truncation failed/
|
76
|
+
)
|
77
|
+
expect(subject.send(notice, promise)).to be_an(Airbrake::Promise)
|
84
78
|
expect(promise.value).
|
85
79
|
to match('error' => '**Airbrake: data was not sent because of missing body')
|
86
|
-
expect(stdout.string).to match(/ERROR -- : .+ data was not sent/)
|
87
80
|
end
|
88
81
|
end
|
89
82
|
|
@@ -100,11 +93,11 @@ RSpec.describe Airbrake::SyncSender do
|
|
100
93
|
|
101
94
|
it "returns error" do
|
102
95
|
p1 = Airbrake::Promise.new
|
103
|
-
|
96
|
+
subject.send({}, p1)
|
104
97
|
expect(p1.value).to match('error' => '**Airbrake: IP is rate limited')
|
105
98
|
|
106
99
|
p2 = Airbrake::Promise.new
|
107
|
-
|
100
|
+
subject.send({}, p2)
|
108
101
|
expect(p2.value).to match('error' => '**Airbrake: IP is rate limited')
|
109
102
|
|
110
103
|
# Wait for X-RateLimit-Delay and then make a new request to make sure p2
|
@@ -112,7 +105,7 @@ RSpec.describe Airbrake::SyncSender do
|
|
112
105
|
sleep 1
|
113
106
|
|
114
107
|
p3 = Airbrake::Promise.new
|
115
|
-
|
108
|
+
subject.send({}, p3)
|
116
109
|
expect(p3.value).to match('error' => '**Airbrake: IP is rate limited')
|
117
110
|
|
118
111
|
expect(a_request(:post, endpoint)).to have_been_made.twice
|
@@ -123,7 +116,7 @@ RSpec.describe Airbrake::SyncSender do
|
|
123
116
|
before { stub_request(:put, endpoint).to_return(status: 200, body: '') }
|
124
117
|
|
125
118
|
it "PUTs the request" do
|
126
|
-
sender = described_class.new(
|
119
|
+
sender = described_class.new(:put)
|
127
120
|
sender.send({}, promise)
|
128
121
|
expect(a_request(:put, endpoint)).to have_been_made
|
129
122
|
end
|
@@ -131,7 +124,7 @@ RSpec.describe Airbrake::SyncSender do
|
|
131
124
|
|
132
125
|
context "when the provided method is :post" do
|
133
126
|
it "POSTs the request" do
|
134
|
-
sender = described_class.new(
|
127
|
+
sender = described_class.new(:post)
|
135
128
|
sender.send({}, promise)
|
136
129
|
expect(a_request(:post, endpoint)).to have_been_made
|
137
130
|
end
|