exception_notification 4.4.0 → 4.5.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.
- checksums.yaml +5 -5
- data/Appraisals +3 -1
- data/CHANGELOG.rdoc +33 -0
- data/Gemfile +2 -0
- data/README.md +36 -13
- data/Rakefile +2 -0
- data/examples/sample_app.rb +2 -0
- data/examples/sinatra/Gemfile +2 -0
- data/examples/sinatra/config.ru +2 -0
- data/examples/sinatra/sinatra_app.rb +6 -2
- data/exception_notification.gemspec +13 -12
- data/gemfiles/rails5_2.gemfile +3 -3
- data/gemfiles/rails6_1.gemfile +7 -0
- data/gemfiles/rails7_0.gemfile +7 -0
- data/lib/exception_notification/rack.rb +24 -13
- data/lib/exception_notification/rails.rb +2 -0
- data/lib/exception_notification/resque.rb +2 -0
- data/lib/exception_notification/sidekiq.rb +5 -3
- data/lib/exception_notification/version.rb +3 -1
- data/lib/exception_notification.rb +2 -0
- data/lib/exception_notifier/base_notifier.rb +8 -2
- data/lib/exception_notifier/datadog_notifier.rb +12 -9
- data/lib/exception_notifier/email_notifier.rb +10 -2
- data/lib/exception_notifier/google_chat_notifier.rb +2 -0
- data/lib/exception_notifier/hipchat_notifier.rb +2 -0
- data/lib/exception_notifier/irc_notifier.rb +4 -3
- data/lib/exception_notifier/mattermost_notifier.rb +10 -0
- data/lib/exception_notifier/modules/backtrace_cleaner.rb +2 -0
- data/lib/exception_notifier/modules/error_grouping.rb +20 -9
- data/lib/exception_notifier/modules/formatter.rb +8 -1
- data/lib/exception_notifier/notifier.rb +5 -1
- data/lib/exception_notifier/slack_notifier.rb +2 -0
- data/lib/exception_notifier/sns_notifier.rb +7 -3
- data/lib/exception_notifier/teams_notifier.rb +10 -3
- data/lib/exception_notifier/webhook_notifier.rb +3 -3
- data/lib/exception_notifier.rb +46 -8
- data/lib/generators/exception_notification/install_generator.rb +8 -2
- data/test/exception_notification/rack_test.rb +48 -2
- data/test/exception_notification/resque_test.rb +2 -0
- data/test/exception_notifier/datadog_notifier_test.rb +2 -0
- data/test/exception_notifier/email_notifier_test.rb +11 -5
- data/test/exception_notifier/google_chat_notifier_test.rb +15 -11
- data/test/exception_notifier/hipchat_notifier_test.rb +8 -2
- data/test/exception_notifier/irc_notifier_test.rb +2 -0
- data/test/exception_notifier/mattermost_notifier_test.rb +73 -24
- data/test/exception_notifier/modules/error_grouping_test.rb +2 -0
- data/test/exception_notifier/modules/formatter_test.rb +2 -0
- data/test/exception_notifier/sidekiq_test.rb +3 -11
- data/test/exception_notifier/slack_notifier_test.rb +12 -10
- data/test/exception_notifier/sns_notifier_test.rb +64 -7
- data/test/exception_notifier/teams_notifier_test.rb +2 -0
- data/test/exception_notifier/webhook_notifier_test.rb +6 -4
- data/test/exception_notifier_test.rb +112 -6
- data/test/support/exception_notifier_helper.rb +14 -0
- data/test/test_helper.rb +5 -1
- metadata +45 -56
- data/gemfiles/rails4_0.gemfile +0 -7
- data/gemfiles/rails4_1.gemfile +0 -7
- data/gemfiles/rails4_2.gemfile +0 -7
- data/gemfiles/rails5_0.gemfile +0 -7
- data/gemfiles/rails5_1.gemfile +0 -7
- data/lib/exception_notifier/campfire_notifier.rb +0 -39
- data/test/exception_notifier/campfire_notifier_test.rb +0 -120
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: exception_notification
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jamis Buck
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: actionmailer
|
|
@@ -17,40 +17,40 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
20
|
+
version: '5.2'
|
|
21
21
|
- - "<"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: '
|
|
23
|
+
version: '8'
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
27
|
requirements:
|
|
28
28
|
- - ">="
|
|
29
29
|
- !ruby/object:Gem::Version
|
|
30
|
-
version: '
|
|
30
|
+
version: '5.2'
|
|
31
31
|
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
33
|
+
version: '8'
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: activesupport
|
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
40
|
+
version: '5.2'
|
|
41
41
|
- - "<"
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '
|
|
43
|
+
version: '8'
|
|
44
44
|
type: :runtime
|
|
45
45
|
prerelease: false
|
|
46
46
|
version_requirements: !ruby/object:Gem::Requirement
|
|
47
47
|
requirements:
|
|
48
48
|
- - ">="
|
|
49
49
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: '
|
|
50
|
+
version: '5.2'
|
|
51
51
|
- - "<"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '
|
|
53
|
+
version: '8'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: appraisal
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -149,54 +149,68 @@ dependencies:
|
|
|
149
149
|
- - "~>"
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
151
|
version: 0.10.2
|
|
152
|
+
- !ruby/object:Gem::Dependency
|
|
153
|
+
name: mocha
|
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - ">="
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: 0.13.0
|
|
159
|
+
type: :development
|
|
160
|
+
prerelease: false
|
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - ">="
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: 0.13.0
|
|
152
166
|
- !ruby/object:Gem::Dependency
|
|
153
167
|
name: mock_redis
|
|
154
168
|
requirement: !ruby/object:Gem::Requirement
|
|
155
169
|
requirements:
|
|
156
170
|
- - "~>"
|
|
157
171
|
- !ruby/object:Gem::Version
|
|
158
|
-
version: 0.
|
|
172
|
+
version: 0.19.0
|
|
159
173
|
type: :development
|
|
160
174
|
prerelease: false
|
|
161
175
|
version_requirements: !ruby/object:Gem::Requirement
|
|
162
176
|
requirements:
|
|
163
177
|
- - "~>"
|
|
164
178
|
- !ruby/object:Gem::Version
|
|
165
|
-
version: 0.
|
|
179
|
+
version: 0.19.0
|
|
166
180
|
- !ruby/object:Gem::Dependency
|
|
167
|
-
name:
|
|
181
|
+
name: net-smtp
|
|
168
182
|
requirement: !ruby/object:Gem::Requirement
|
|
169
183
|
requirements:
|
|
170
184
|
- - ">="
|
|
171
185
|
- !ruby/object:Gem::Version
|
|
172
|
-
version: 0
|
|
186
|
+
version: '0'
|
|
173
187
|
type: :development
|
|
174
188
|
prerelease: false
|
|
175
189
|
version_requirements: !ruby/object:Gem::Requirement
|
|
176
190
|
requirements:
|
|
177
191
|
- - ">="
|
|
178
192
|
- !ruby/object:Gem::Version
|
|
179
|
-
version: 0
|
|
193
|
+
version: '0'
|
|
180
194
|
- !ruby/object:Gem::Dependency
|
|
181
195
|
name: rails
|
|
182
196
|
requirement: !ruby/object:Gem::Requirement
|
|
183
197
|
requirements:
|
|
184
198
|
- - ">="
|
|
185
199
|
- !ruby/object:Gem::Version
|
|
186
|
-
version: '
|
|
200
|
+
version: '5.2'
|
|
187
201
|
- - "<"
|
|
188
202
|
- !ruby/object:Gem::Version
|
|
189
|
-
version: '
|
|
203
|
+
version: '8'
|
|
190
204
|
type: :development
|
|
191
205
|
prerelease: false
|
|
192
206
|
version_requirements: !ruby/object:Gem::Requirement
|
|
193
207
|
requirements:
|
|
194
208
|
- - ">="
|
|
195
209
|
- !ruby/object:Gem::Version
|
|
196
|
-
version: '
|
|
210
|
+
version: '5.2'
|
|
197
211
|
- - "<"
|
|
198
212
|
- !ruby/object:Gem::Version
|
|
199
|
-
version: '
|
|
213
|
+
version: '8'
|
|
200
214
|
- !ruby/object:Gem::Dependency
|
|
201
215
|
name: resque
|
|
202
216
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -217,34 +231,28 @@ dependencies:
|
|
|
217
231
|
requirements:
|
|
218
232
|
- - '='
|
|
219
233
|
- !ruby/object:Gem::Version
|
|
220
|
-
version: 0.
|
|
234
|
+
version: 0.78.0
|
|
221
235
|
type: :development
|
|
222
236
|
prerelease: false
|
|
223
237
|
version_requirements: !ruby/object:Gem::Requirement
|
|
224
238
|
requirements:
|
|
225
239
|
- - '='
|
|
226
240
|
- !ruby/object:Gem::Version
|
|
227
|
-
version: 0.
|
|
241
|
+
version: 0.78.0
|
|
228
242
|
- !ruby/object:Gem::Dependency
|
|
229
243
|
name: sidekiq
|
|
230
244
|
requirement: !ruby/object:Gem::Requirement
|
|
231
245
|
requirements:
|
|
232
|
-
- - "
|
|
233
|
-
- !ruby/object:Gem::Version
|
|
234
|
-
version: 3.0.0
|
|
235
|
-
- - "<"
|
|
246
|
+
- - ">="
|
|
236
247
|
- !ruby/object:Gem::Version
|
|
237
|
-
version:
|
|
248
|
+
version: 5.0.4
|
|
238
249
|
type: :development
|
|
239
250
|
prerelease: false
|
|
240
251
|
version_requirements: !ruby/object:Gem::Requirement
|
|
241
252
|
requirements:
|
|
242
|
-
- - "
|
|
243
|
-
- !ruby/object:Gem::Version
|
|
244
|
-
version: 3.0.0
|
|
245
|
-
- - "<"
|
|
253
|
+
- - ">="
|
|
246
254
|
- !ruby/object:Gem::Version
|
|
247
|
-
version:
|
|
255
|
+
version: 5.0.4
|
|
248
256
|
- !ruby/object:Gem::Dependency
|
|
249
257
|
name: slack-notifier
|
|
250
258
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -273,20 +281,6 @@ dependencies:
|
|
|
273
281
|
- - "~>"
|
|
274
282
|
- !ruby/object:Gem::Version
|
|
275
283
|
version: 0.9.0
|
|
276
|
-
- !ruby/object:Gem::Dependency
|
|
277
|
-
name: tinder
|
|
278
|
-
requirement: !ruby/object:Gem::Requirement
|
|
279
|
-
requirements:
|
|
280
|
-
- - "~>"
|
|
281
|
-
- !ruby/object:Gem::Version
|
|
282
|
-
version: '1.8'
|
|
283
|
-
type: :development
|
|
284
|
-
prerelease: false
|
|
285
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
286
|
-
requirements:
|
|
287
|
-
- - "~>"
|
|
288
|
-
- !ruby/object:Gem::Version
|
|
289
|
-
version: '1.8'
|
|
290
284
|
description:
|
|
291
285
|
email: smartinez87@gmail.com
|
|
292
286
|
executables: []
|
|
@@ -321,13 +315,10 @@ files:
|
|
|
321
315
|
- examples/sinatra/config.ru
|
|
322
316
|
- examples/sinatra/sinatra_app.rb
|
|
323
317
|
- exception_notification.gemspec
|
|
324
|
-
- gemfiles/rails4_0.gemfile
|
|
325
|
-
- gemfiles/rails4_1.gemfile
|
|
326
|
-
- gemfiles/rails4_2.gemfile
|
|
327
|
-
- gemfiles/rails5_0.gemfile
|
|
328
|
-
- gemfiles/rails5_1.gemfile
|
|
329
318
|
- gemfiles/rails5_2.gemfile
|
|
330
319
|
- gemfiles/rails6_0.gemfile
|
|
320
|
+
- gemfiles/rails6_1.gemfile
|
|
321
|
+
- gemfiles/rails7_0.gemfile
|
|
331
322
|
- lib/exception_notification.rb
|
|
332
323
|
- lib/exception_notification/rack.rb
|
|
333
324
|
- lib/exception_notification/rails.rb
|
|
@@ -336,7 +327,6 @@ files:
|
|
|
336
327
|
- lib/exception_notification/version.rb
|
|
337
328
|
- lib/exception_notifier.rb
|
|
338
329
|
- lib/exception_notifier/base_notifier.rb
|
|
339
|
-
- lib/exception_notifier/campfire_notifier.rb
|
|
340
330
|
- lib/exception_notifier/datadog_notifier.rb
|
|
341
331
|
- lib/exception_notifier/email_notifier.rb
|
|
342
332
|
- lib/exception_notifier/google_chat_notifier.rb
|
|
@@ -371,7 +361,6 @@ files:
|
|
|
371
361
|
- lib/generators/exception_notification/templates/exception_notification.rb.erb
|
|
372
362
|
- test/exception_notification/rack_test.rb
|
|
373
363
|
- test/exception_notification/resque_test.rb
|
|
374
|
-
- test/exception_notifier/campfire_notifier_test.rb
|
|
375
364
|
- test/exception_notifier/datadog_notifier_test.rb
|
|
376
365
|
- test/exception_notifier/email_notifier_test.rb
|
|
377
366
|
- test/exception_notifier/google_chat_notifier_test.rb
|
|
@@ -386,6 +375,7 @@ files:
|
|
|
386
375
|
- test/exception_notifier/teams_notifier_test.rb
|
|
387
376
|
- test/exception_notifier/webhook_notifier_test.rb
|
|
388
377
|
- test/exception_notifier_test.rb
|
|
378
|
+
- test/support/exception_notifier_helper.rb
|
|
389
379
|
- test/support/views/exception_notifier/_new_bkg_section.html.erb
|
|
390
380
|
- test/support/views/exception_notifier/_new_bkg_section.text.erb
|
|
391
381
|
- test/support/views/exception_notifier/_new_section.html.erb
|
|
@@ -403,22 +393,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
403
393
|
requirements:
|
|
404
394
|
- - ">="
|
|
405
395
|
- !ruby/object:Gem::Version
|
|
406
|
-
version: '2.
|
|
396
|
+
version: '2.3'
|
|
407
397
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
408
398
|
requirements:
|
|
409
399
|
- - ">="
|
|
410
400
|
- !ruby/object:Gem::Version
|
|
411
401
|
version: 1.8.11
|
|
412
402
|
requirements: []
|
|
413
|
-
|
|
414
|
-
rubygems_version: 2.5.1
|
|
403
|
+
rubygems_version: 3.2.32
|
|
415
404
|
signing_key:
|
|
416
405
|
specification_version: 4
|
|
417
406
|
summary: Exception notification for Rails apps
|
|
418
407
|
test_files:
|
|
419
408
|
- test/exception_notification/rack_test.rb
|
|
420
409
|
- test/exception_notification/resque_test.rb
|
|
421
|
-
- test/exception_notifier/campfire_notifier_test.rb
|
|
422
410
|
- test/exception_notifier/datadog_notifier_test.rb
|
|
423
411
|
- test/exception_notifier/email_notifier_test.rb
|
|
424
412
|
- test/exception_notifier/google_chat_notifier_test.rb
|
|
@@ -433,6 +421,7 @@ test_files:
|
|
|
433
421
|
- test/exception_notifier/teams_notifier_test.rb
|
|
434
422
|
- test/exception_notifier/webhook_notifier_test.rb
|
|
435
423
|
- test/exception_notifier_test.rb
|
|
424
|
+
- test/support/exception_notifier_helper.rb
|
|
436
425
|
- test/support/views/exception_notifier/_new_bkg_section.html.erb
|
|
437
426
|
- test/support/views/exception_notifier/_new_bkg_section.text.erb
|
|
438
427
|
- test/support/views/exception_notifier/_new_section.html.erb
|
data/gemfiles/rails4_0.gemfile
DELETED
data/gemfiles/rails4_1.gemfile
DELETED
data/gemfiles/rails4_2.gemfile
DELETED
data/gemfiles/rails5_0.gemfile
DELETED
data/gemfiles/rails5_1.gemfile
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module ExceptionNotifier
|
|
2
|
-
class CampfireNotifier < BaseNotifier
|
|
3
|
-
attr_accessor :subdomain
|
|
4
|
-
attr_accessor :token
|
|
5
|
-
attr_accessor :room
|
|
6
|
-
|
|
7
|
-
def initialize(options)
|
|
8
|
-
super
|
|
9
|
-
begin
|
|
10
|
-
subdomain = options.delete(:subdomain)
|
|
11
|
-
room_name = options.delete(:room_name)
|
|
12
|
-
@campfire = Tinder::Campfire.new subdomain, options
|
|
13
|
-
@room = @campfire.find_room_by_name room_name
|
|
14
|
-
rescue StandardError
|
|
15
|
-
@campfire = @room = nil
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def call(exception, options = {})
|
|
20
|
-
return unless active?
|
|
21
|
-
|
|
22
|
-
message = if options[:accumulated_errors_count].to_i > 1
|
|
23
|
-
"The exception occurred #{options[:accumulated_errors_count]} times: '#{exception.message}'"
|
|
24
|
-
else
|
|
25
|
-
"A new exception occurred: '#{exception.message}'"
|
|
26
|
-
end
|
|
27
|
-
message += " on '#{exception.backtrace.first}'" if exception.backtrace
|
|
28
|
-
send_notice(exception, options, message) do |msg, _|
|
|
29
|
-
@room.paste msg
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def active?
|
|
36
|
-
!@room.nil?
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
# silence_warnings trick around require can be removed once
|
|
4
|
-
# https://github.com/collectiveidea/tinder/pull/77
|
|
5
|
-
# gets merged and released
|
|
6
|
-
silence_warnings do
|
|
7
|
-
require 'tinder'
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
class CampfireNotifierTest < ActiveSupport::TestCase
|
|
11
|
-
test 'should send campfire notification if properly configured' do
|
|
12
|
-
ExceptionNotifier::CampfireNotifier.stubs(:new).returns(Object.new)
|
|
13
|
-
campfire = ExceptionNotifier::CampfireNotifier.new(subdomain: 'test', token: 'test_token', room_name: 'test_room')
|
|
14
|
-
campfire.stubs(:call).returns(fake_notification)
|
|
15
|
-
notif = campfire.call(fake_exception)
|
|
16
|
-
|
|
17
|
-
assert !notif[:message].empty?
|
|
18
|
-
assert_equal notif[:message][:type], 'PasteMessage'
|
|
19
|
-
assert_includes notif[:message][:body], 'A new exception occurred:'
|
|
20
|
-
assert_includes notif[:message][:body], 'divided by 0'
|
|
21
|
-
assert_includes notif[:message][:body], '/exception_notification/test/campfire_test.rb:45'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
test 'should send campfire notification without backtrace info if properly configured' do
|
|
25
|
-
ExceptionNotifier::CampfireNotifier.stubs(:new).returns(Object.new)
|
|
26
|
-
campfire = ExceptionNotifier::CampfireNotifier.new(subdomain: 'test', token: 'test_token', room_name: 'test_room')
|
|
27
|
-
campfire.stubs(:call).returns(fake_notification_without_backtrace)
|
|
28
|
-
notif = campfire.call(fake_exception_without_backtrace)
|
|
29
|
-
|
|
30
|
-
assert !notif[:message].empty?
|
|
31
|
-
assert_equal notif[:message][:type], 'PasteMessage'
|
|
32
|
-
assert_includes notif[:message][:body], 'A new exception occurred:'
|
|
33
|
-
assert_includes notif[:message][:body], 'my custom error'
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
test 'should not send campfire notification if badly configured' do
|
|
37
|
-
wrong_params = { subdomain: 'test', token: 'bad_token', room_name: 'test_room' }
|
|
38
|
-
Tinder::Campfire.stubs(:new).with('test', token: 'bad_token').returns(nil)
|
|
39
|
-
campfire = ExceptionNotifier::CampfireNotifier.new(wrong_params)
|
|
40
|
-
|
|
41
|
-
assert_nil campfire.room
|
|
42
|
-
assert_nil campfire.call(fake_exception)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test 'should not send campfire notification if config attr missing' do
|
|
46
|
-
wrong_params = { subdomain: 'test', room_name: 'test_room' }
|
|
47
|
-
Tinder::Campfire.stubs(:new).with('test', {}).returns(nil)
|
|
48
|
-
campfire = ExceptionNotifier::CampfireNotifier.new(wrong_params)
|
|
49
|
-
|
|
50
|
-
assert_nil campfire.room
|
|
51
|
-
assert_nil campfire.call(fake_exception)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
test 'should send the new exception message if no :accumulated_errors_count option' do
|
|
55
|
-
campfire = ExceptionNotifier::CampfireNotifier.new({})
|
|
56
|
-
campfire.stubs(:active?).returns(true)
|
|
57
|
-
campfire.expects(:send_notice).with { |_, _, message| message.start_with?('A new exception occurred') }.once
|
|
58
|
-
campfire.call(fake_exception)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
test 'shoud send the exception message if :accumulated_errors_count option greater than 1' do
|
|
62
|
-
campfire = ExceptionNotifier::CampfireNotifier.new({})
|
|
63
|
-
campfire.stubs(:active?).returns(true)
|
|
64
|
-
campfire.expects(:send_notice).with { |_, _, message| message.start_with?('The exception occurred 3 times:') }.once
|
|
65
|
-
campfire.call(fake_exception, accumulated_errors_count: 3)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
test 'should call pre/post_callback if specified' do
|
|
69
|
-
pre_callback_called = 0
|
|
70
|
-
post_callback_called = 0
|
|
71
|
-
Tinder::Campfire.stubs(:new).returns(Object.new)
|
|
72
|
-
|
|
73
|
-
campfire = ExceptionNotifier::CampfireNotifier.new(
|
|
74
|
-
subdomain: 'test',
|
|
75
|
-
token: 'test_token',
|
|
76
|
-
room_name: 'test_room',
|
|
77
|
-
pre_callback: proc { |_opts, _notifier, _backtrace, _message, _message_opts|
|
|
78
|
-
pre_callback_called += 1
|
|
79
|
-
},
|
|
80
|
-
post_callback: proc { |_opts, _notifier, _backtrace, _message, _message_opts|
|
|
81
|
-
post_callback_called += 1
|
|
82
|
-
}
|
|
83
|
-
)
|
|
84
|
-
campfire.room = Object.new
|
|
85
|
-
campfire.room.stubs(:paste).returns(fake_notification)
|
|
86
|
-
campfire.call(fake_exception)
|
|
87
|
-
assert_equal(1, pre_callback_called)
|
|
88
|
-
assert_equal(1, post_callback_called)
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
private
|
|
92
|
-
|
|
93
|
-
def fake_notification
|
|
94
|
-
{
|
|
95
|
-
message: {
|
|
96
|
-
type: 'PasteMessage',
|
|
97
|
-
body: "A new exception occurred: 'divided by 0' on '/Users/sebastian/exception_notification/test/campfire_test.rb:45:in `/'"
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def fake_exception
|
|
103
|
-
5 / 0
|
|
104
|
-
rescue StandardError => e
|
|
105
|
-
e
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def fake_notification_without_backtrace
|
|
109
|
-
{
|
|
110
|
-
message: {
|
|
111
|
-
type: 'PasteMessage',
|
|
112
|
-
body: "A new exception occurred: 'my custom error'"
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def fake_exception_without_backtrace
|
|
118
|
-
StandardError.new('my custom error')
|
|
119
|
-
end
|
|
120
|
-
end
|