airbrake-ruby 4.0.1-java → 4.1.0-java

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.
@@ -1,13 +1,24 @@
1
1
  RSpec.describe Airbrake::DeployNotifier do
2
- before { Airbrake::Config.instance = Airbrake::Config.new(project_id: 1) }
2
+ before do
3
+ Airbrake::Config.instance = Airbrake::Config.new(project_id: 1, project_key: '123')
4
+ end
3
5
 
4
6
  describe "#notify" do
5
7
  it "returns a promise" do
6
- stub_request(:post, 'https://api.airbrake.io/api/v4/projects/1/deploys').
7
- to_return(status: 201, body: '{}')
8
+ stub_request(:post, 'https://api.airbrake.io/api/v4/projects/1/deploys')
9
+ .to_return(status: 201, body: '{}')
8
10
  expect(subject.notify({})).to be_an(Airbrake::Promise)
9
11
  end
10
12
 
13
+ context "when config is invalid" do
14
+ before { Airbrake::Config.instance.merge(project_id: nil) }
15
+
16
+ it "returns a rejected promise" do
17
+ promise = subject.notify({})
18
+ expect(promise).to be_rejected
19
+ end
20
+ end
21
+
11
22
  context "when environment is configured" do
12
23
  before { Airbrake::Config.instance.merge(environment: 'fooenv') }
13
24
 
@@ -7,20 +7,20 @@ RSpec.describe Airbrake::Filters::GitRepositoryFilter do
7
7
 
8
8
  describe "#initialize" do
9
9
  it "parses standard git version" do
10
- allow_any_instance_of(Kernel).
11
- to receive(:`).and_return('git version 2.18.0')
10
+ allow_any_instance_of(Kernel)
11
+ .to receive(:`).and_return('git version 2.18.0')
12
12
  expect { subject }.not_to raise_error
13
13
  end
14
14
 
15
15
  it "parses release candidate git version" do
16
- allow_any_instance_of(Kernel).
17
- to receive(:`).and_return('git version 2.21.0-rc0')
16
+ allow_any_instance_of(Kernel)
17
+ .to receive(:`).and_return('git version 2.21.0-rc0')
18
18
  expect { subject }.not_to raise_error
19
19
  end
20
20
 
21
21
  it "parses git version with brackets" do
22
- allow_any_instance_of(Kernel).
23
- to receive(:`).and_return('git version 2.17.2 (Apple Git-113)')
22
+ allow_any_instance_of(Kernel)
23
+ .to receive(:`).and_return('git version 2.17.2 (Apple Git-113)')
24
24
  expect { subject }.not_to raise_error
25
25
  end
26
26
  end
@@ -1,4 +1,3 @@
1
- # rubocop:disable Layout/DotPosition
2
1
  RSpec.describe Airbrake::NoticeNotifier do
3
2
  before do
4
3
  Airbrake::Config.instance = Airbrake::Config.new(
@@ -108,6 +107,15 @@ RSpec.describe Airbrake::NoticeNotifier do
108
107
  sleep 1
109
108
  end
110
109
 
110
+ context "when config is invalid" do
111
+ before { Airbrake::Config.instance.merge(project_id: nil) }
112
+
113
+ it "returns a rejected promise" do
114
+ promise = subject.notify({})
115
+ expect(promise).to be_rejected
116
+ end
117
+ end
118
+
111
119
  context "when a notice is not ignored" do
112
120
  it "yields the notice" do
113
121
  expect { |b| subject.notify('ex', &b) }
@@ -169,7 +177,7 @@ RSpec.describe Airbrake::NoticeNotifier do
169
177
 
170
178
  it "returns a rejected promise" do
171
179
  promise = subject.notify('foo', bingo: 'bango')
172
- expect(promise.value).to eq('error' => "The 'test' environment is ignored")
180
+ expect(promise.value).to eq('error' => "current environment 'test' is ignored")
173
181
  end
174
182
  end
175
183
  end
@@ -253,7 +261,7 @@ RSpec.describe Airbrake::NoticeNotifier do
253
261
 
254
262
  it "returns an error hash" do
255
263
  expect(subject.notify_sync('foo'))
256
- .to eq('error' => "The 'test' environment is ignored")
264
+ .to eq('error' => "current environment 'test' is ignored")
257
265
  end
258
266
  end
259
267
  end
@@ -406,4 +414,3 @@ RSpec.describe Airbrake::NoticeNotifier do
406
414
  end
407
415
  end
408
416
  end
409
- # rubocop:enable Layout/DotPosition
@@ -74,8 +74,8 @@ RSpec.describe Airbrake::NoticeNotifier do
74
74
  subject.notify_sync(ex)
75
75
 
76
76
  expect(
77
- a_request(:post, endpoint).
78
- with(body: %r|{"file":"/PROJECT_ROOT/airbrake/ruby/spec/airbrake_spec.+|)
77
+ a_request(:post, endpoint)
78
+ .with(body: %r|{"file":"/PROJECT_ROOT/airbrake/ruby/spec/airbrake_spec.+|)
79
79
  ).to have_been_made.once
80
80
  end
81
81
 
@@ -86,8 +86,8 @@ RSpec.describe Airbrake::NoticeNotifier do
86
86
  it "being included into the notice's payload" do
87
87
  subject.notify_sync(ex)
88
88
  expect(
89
- a_request(:post, endpoint).
90
- with(body: %r{"rootDirectory":"/bingo/bango"})
89
+ a_request(:post, endpoint)
90
+ .with(body: %r{"rootDirectory":"/bingo/bango"})
91
91
  ).to have_been_made.once
92
92
  end
93
93
  end
@@ -148,12 +148,12 @@ RSpec.describe Airbrake::NoticeNotifier do
148
148
 
149
149
  proxied_request = requests.pop(true)
150
150
 
151
- expect(proxied_request.header['proxy-authorization'].first).
152
- to eq('Basic dXNlcjpwYXNzd29yZA==')
151
+ expect(proxied_request.header['proxy-authorization'].first)
152
+ .to eq('Basic dXNlcjpwYXNzd29yZA==')
153
153
 
154
154
  # rubocop:disable Metrics/LineLength
155
- expect(proxied_request.request_line).
156
- to eq("POST http://localhost:#{proxy.config[:Port]}/api/v3/projects/105138/notices HTTP/1.1\r\n")
155
+ expect(proxied_request.request_line)
156
+ .to eq("POST http://localhost:#{proxy.config[:Port]}/api/v3/projects/105138/notices HTTP/1.1\r\n")
157
157
  # rubocop:enable Metrics/LineLength
158
158
  end
159
159
  end
@@ -165,8 +165,8 @@ RSpec.describe Airbrake::NoticeNotifier do
165
165
  it "being included into the notice's payload" do
166
166
  subject.notify_sync(ex)
167
167
  expect(
168
- a_request(:post, endpoint).
169
- with(body: /"context":{.*"environment":"production".*}/)
168
+ a_request(:post, endpoint)
169
+ .with(body: /"context":{.*"environment":"production".*}/)
170
170
  ).to have_been_made.once
171
171
  end
172
172
  end
@@ -210,8 +210,8 @@ RSpec.describe Airbrake::NoticeNotifier do
210
210
 
211
211
  it "returns early and doesn't try to parse the given exception" do
212
212
  expect(Airbrake::Notice).not_to receive(:new)
213
- expect(subject.notify_sync(ex)).
214
- to eq('error' => "The 'development' environment is ignored")
213
+ expect(subject.notify_sync(ex))
214
+ .to eq('error' => "current environment 'development' is ignored")
215
215
  expect(a_request(:post, endpoint)).not_to have_been_made
216
216
  end
217
217
  end
@@ -85,8 +85,8 @@ RSpec.describe Airbrake::Notice do
85
85
 
86
86
  context "when truncation failed" do
87
87
  it "returns nil" do
88
- expect_any_instance_of(Airbrake::Truncator).
89
- to receive(:reduce_max_size).and_return(0)
88
+ expect_any_instance_of(Airbrake::Truncator)
89
+ .to receive(:reduce_max_size).and_return(0)
90
90
 
91
91
  encoded = Base64.encode64("\xD3\xE6\xBC\x9D\xBA").encode!('ASCII-8BIT')
92
92
  bad_string = Base64.decode64(encoded)
@@ -118,8 +118,8 @@ RSpec.describe Airbrake::Notice do
118
118
  let(:backtrace_size) { 1000 }
119
119
 
120
120
  it "doesn't happen" do
121
- expect(notice.to_json).
122
- to match(/bingo":\["#<Object:.+>","#<#<Class:.+>:.+>"/)
121
+ expect(notice.to_json)
122
+ .to match(/bingo":\["#<Object:.+>","#<#<Class:.+>:.+>"/)
123
123
  end
124
124
  end
125
125
 
@@ -128,8 +128,8 @@ RSpec.describe Airbrake::Notice do
128
128
  let(:backtrace_size) { 50_000 }
129
129
 
130
130
  it "happens" do
131
- expect(notice.to_json).
132
- to match(/bingo":\[".+Object.+",".+Class.+"/)
131
+ expect(notice.to_json)
132
+ .to match(/bingo":\[".+Object.+",".+Class.+"/)
133
133
  end
134
134
  end
135
135
  end
@@ -219,13 +219,13 @@ RSpec.describe Airbrake::Notice do
219
219
  it "overwrites the 'notifier' payload with the default values" do
220
220
  notice[:notifier] = { name: 'bingo', bango: 'bongo' }
221
221
 
222
- expect(notice.to_json).
223
- to match(/"notifier":{"name":"airbrake-ruby","version":".+","url":".+"}/)
222
+ expect(notice.to_json)
223
+ .to match(/"notifier":{"name":"airbrake-ruby","version":".+","url":".+"}/)
224
224
  end
225
225
 
226
226
  it "always contains context/hostname" do
227
- expect(notice.to_json).
228
- to match(/"context":{.*"hostname":".+".*}/)
227
+ expect(notice.to_json)
228
+ .to match(/"context":{.*"hostname":".+".*}/)
229
229
  end
230
230
 
231
231
  it "defaults to the error severity" do
@@ -233,18 +233,18 @@ RSpec.describe Airbrake::Notice do
233
233
  end
234
234
 
235
235
  it "always contains environment/program_name" do
236
- expect(notice.to_json).
237
- to match(%r|"environment":{"program_name":.+/rspec.*|)
236
+ expect(notice.to_json)
237
+ .to match(%r|"environment":{"program_name":.+/rspec.*|)
238
238
  end
239
239
 
240
240
  it "contains errors" do
241
- expect(notice.to_json).
242
- to match(/"errors":\[{"type":"AirbrakeTestError","message":"App crash/)
241
+ expect(notice.to_json)
242
+ .to match(/"errors":\[{"type":"AirbrakeTestError","message":"App crash/)
243
243
  end
244
244
 
245
245
  it "contains a backtrace" do
246
- expect(notice.to_json).
247
- to match(%r|"backtrace":\[{"file":"/home/.+/spec/spec_helper.rb"|)
246
+ expect(notice.to_json)
247
+ .to match(%r|"backtrace":\[{"file":"/home/.+/spec/spec_helper.rb"|)
248
248
  end
249
249
 
250
250
  it "contains params" do
@@ -259,8 +259,8 @@ RSpec.describe Airbrake::Notice do
259
259
 
260
260
  it "raises error if notice is ignored" do
261
261
  notice.ignore!
262
- expect { notice[:params] }.
263
- to raise_error(Airbrake::Error, 'cannot access ignored Airbrake::Notice')
262
+ expect { notice[:params] }
263
+ .to raise_error(Airbrake::Error, 'cannot access ignored Airbrake::Notice')
264
264
  end
265
265
  end
266
266
 
@@ -273,18 +273,18 @@ RSpec.describe Airbrake::Notice do
273
273
 
274
274
  it "raises error if notice is ignored" do
275
275
  notice.ignore!
276
- expect { notice[:params] = {} }.
277
- to raise_error(Airbrake::Error, 'cannot access ignored Airbrake::Notice')
276
+ expect { notice[:params] = {} }
277
+ .to raise_error(Airbrake::Error, 'cannot access ignored Airbrake::Notice')
278
278
  end
279
279
 
280
280
  it "raises error when trying to assign unrecognized key" do
281
- expect { notice[:bingo] = 1 }.
282
- to raise_error(Airbrake::Error, /:bingo is not recognized among/)
281
+ expect { notice[:bingo] = 1 }
282
+ .to raise_error(Airbrake::Error, /:bingo is not recognized among/)
283
283
  end
284
284
 
285
285
  it "raises when setting non-hash objects as the value" do
286
- expect { notice[:params] = Object.new }.
287
- to raise_error(Airbrake::Error, 'Got Object value, wanted a Hash')
286
+ expect { notice[:params] = Object.new }
287
+ .to raise_error(Airbrake::Error, 'Got Object value, wanted a Hash')
288
288
  end
289
289
  end
290
290
 
@@ -217,7 +217,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
217
217
  )
218
218
 
219
219
  expect(a_request(:put, routes)).not_to have_been_made
220
- expect(promise.value).to eq('error' => "The 'test' environment is ignored")
220
+ expect(promise.value).to eq('error' => "current environment 'test' is ignored")
221
221
  end
222
222
 
223
223
  it "sends environment when it's specified" do
@@ -238,6 +238,15 @@ RSpec.describe Airbrake::PerformanceNotifier do
238
238
  ).to have_been_made
239
239
  end
240
240
 
241
+ context "when config is invalid" do
242
+ before { Airbrake::Config.instance.merge(project_id: nil) }
243
+
244
+ it "returns a rejected promise" do
245
+ promise = subject.notify({})
246
+ expect(promise).to be_rejected
247
+ end
248
+ end
249
+
241
250
  describe "payload grouping" do
242
251
  let(:flush_period) { 0.5 }
243
252
 
@@ -162,4 +162,36 @@ RSpec.describe Airbrake::Promise do
162
162
  expect(array).to match_array([999])
163
163
  end
164
164
  end
165
+
166
+ describe "#rejected?" do
167
+ context "when it was rejected" do
168
+ before { subject.reject(1) }
169
+ it { is_expected.to be_rejected }
170
+ end
171
+
172
+ context "when it wasn't rejected" do
173
+ it { is_expected.not_to be_rejected }
174
+ end
175
+
176
+ context "when it was resolved" do
177
+ before { subject.resolve }
178
+ it { is_expected.not_to be_rejected }
179
+ end
180
+ end
181
+
182
+ describe "#resolved?" do
183
+ context "when it was resolved" do
184
+ before { subject.resolve }
185
+ it { is_expected.to be_resolved }
186
+ end
187
+
188
+ context "when it wasn't resolved" do
189
+ it { is_expected.not_to be_resolved }
190
+ end
191
+
192
+ context "when it was rejected" do
193
+ before { subject.reject(1) }
194
+ it { is_expected.not_to be_resolved }
195
+ end
196
+ end
165
197
  end
@@ -1,5 +1,7 @@
1
1
  require 'airbrake-ruby'
2
2
 
3
+ require 'rspec/its'
4
+
3
5
  require 'webmock'
4
6
  require 'webmock/rspec'
5
7
  require 'pry'
@@ -55,8 +55,8 @@ RSpec.describe Airbrake::SyncSender do
55
55
 
56
56
  context "when request body is nil" do
57
57
  it "doesn't send data" do
58
- expect_any_instance_of(Airbrake::Truncator).
59
- to receive(:reduce_max_size).and_return(0)
58
+ expect_any_instance_of(Airbrake::Truncator)
59
+ .to receive(:reduce_max_size).and_return(0)
60
60
 
61
61
  encoded = Base64.encode64("\xD3\xE6\xBC\x9D\xBA").encode!('ASCII-8BIT')
62
62
  bad_string = Base64.decode64(encoded)
@@ -75,8 +75,8 @@ RSpec.describe Airbrake::SyncSender do
75
75
  /truncation failed/
76
76
  )
77
77
  expect(subject.send(notice, promise)).to be_an(Airbrake::Promise)
78
- expect(promise.value).
79
- to match('error' => '**Airbrake: data was not sent because of missing body')
78
+ expect(promise.value)
79
+ .to match('error' => '**Airbrake: data was not sent because of missing body')
80
80
  end
81
81
  end
82
82
 
@@ -178,8 +178,8 @@ RSpec.describe Airbrake::TDigest do
178
178
 
179
179
  it "returns a tdigest with less than or equal centroids" do
180
180
  new_tdigest = subject + @other
181
- expect(new_tdigest.centroids.size).
182
- to be <= subject.centroids.size + @other.centroids.size
181
+ expect(new_tdigest.centroids.size)
182
+ .to be <= subject.centroids.size + @other.centroids.size
183
183
  end
184
184
 
185
185
  it "has the size of the two digests combined" do
@@ -104,8 +104,8 @@ RSpec.describe Airbrake::Truncator do
104
104
  context "given an arbitrary object that doesn't respond to #to_json" do
105
105
  let(:object) do
106
106
  obj = Object.new
107
- allow(obj).to receive(:to_json).
108
- and_raise(Airbrake::Notice::JSON_EXCEPTIONS.first)
107
+ allow(obj).to receive(:to_json)
108
+ .and_raise(Airbrake::Notice::JSON_EXCEPTIONS.first)
109
109
  obj
110
110
  end
111
111
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-26 00:00:00.000000000 Z
11
+ date: 2019-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree-jruby