barsoom_utils 0.2.0.78 → 0.3.0.79

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f10ec24dca48ed3703590008317664ee7993d1efbfd0b3d4c5cc1d876c5712ca
4
- data.tar.gz: c9d43fdc45e23e2a267c390007cc5c685273d5da581f8a413fb2da106ec25d08
3
+ metadata.gz: d567d7a3ae76f80b86ad642cf590526cb3bc2a2be5b95c94abf8944142a40b15
4
+ data.tar.gz: 0fd5468990225ed9d0faf43d860b6afe2ccb5b24fb5786077cde7054445ea832
5
5
  SHA512:
6
- metadata.gz: bfb7e4a46b94501ce9d505c0b19b674006f75c48cd3b16f18c7573c6d006ab41f9b3196529a5fa6a383d7c2454a41ac12dcfacd3da05db9e40b19f217715ae32
7
- data.tar.gz: f9e748ad9dfb716d217df3420fafb7ac93c859d07b240e24dcd9c668b9ff741f9d6631a6f467abea7ca24a71867e39ed8b37885a4ea53ab15e0ee83f3593b277
6
+ metadata.gz: ce1a9a7ef20a8f445b8974a3e63b471c1b20ca952f2608e2fb6e35a9f502a8ef961f4d9087dd02cc6e41a6ba9e234df7ba812f6cac42d057d49a3cc00ba02abd
7
+ data.tar.gz: 787e53e219778ea27306a49758ce0220fbfa1be5e57743f0b5a14a14fe56288d07f914ae885cacf996e2c02dc9ed35151907457b0a0f1f7e4b2fc2bc818c2483
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ group :development, :test do
8
8
  gem "attr_extras"
9
9
  gem "bundler"
10
10
  gem "fixme"
11
- gem "honeybadger"
12
11
  gem "httparty"
13
12
  gem "lolcat"
14
13
  gem "rake"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.78
1
+ 0.3.0.79
@@ -13,9 +13,7 @@ module BarsoomUtils
13
13
 
14
14
  ensure_notifier!
15
15
 
16
- result = Honeybadger.notify(exception, context: context) if defined?(Honeybadger)
17
- Sentry.capture_exception(exception, extra: context) if defined?(Sentry)
18
- result
16
+ Sentry.capture_exception(exception, extra: context)
19
17
  end
20
18
 
21
19
  def self.message(message, details_or_context = nil, context_or_nothing = nil)
@@ -32,29 +30,17 @@ module BarsoomUtils
32
30
  context = {}
33
31
  end
34
32
 
35
- if defined?(Honeybadger)
36
- result = Honeybadger.notify(
37
- error_class: message,
38
- error_message: (details || "(no message)").to_s,
39
- context: context.to_h,
40
- )
41
- end
42
-
43
- if defined?(Sentry)
44
- title = details ? "#{message}: #{details}" : message.to_s
45
- Sentry.capture_message(title, extra: context.to_h)
46
- end
47
-
48
- result
33
+ title = details ? "#{message}: #{details}" : message.to_s
34
+ Sentry.capture_message(title, extra: context.to_h)
49
35
  end
50
36
 
51
37
  private
52
38
 
53
39
  private_class_method \
54
40
  def self.ensure_notifier!
55
- return if defined?(Honeybadger) || defined?(Sentry)
41
+ return if defined?(Sentry)
56
42
 
57
- raise "Cannot notify: neither Honeybadger nor Sentry is available."
43
+ raise "Cannot notify: Sentry is not available."
58
44
  end
59
45
  end
60
46
  end
@@ -1,12 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
  require "barsoom_utils/exception_notifier"
3
- require "honeybadger"
4
3
  require "sentry-ruby"
5
4
  require "fixme"
6
5
 
7
6
  RSpec.describe BarsoomUtils::ExceptionNotifier do
8
7
  before do
9
- allow(Honeybadger).to receive(:notify)
10
8
  allow(Sentry).to receive(:capture_exception)
11
9
  allow(Sentry).to receive(:capture_message)
12
10
  end
@@ -14,17 +12,15 @@ RSpec.describe BarsoomUtils::ExceptionNotifier do
14
12
  describe ".notify" do
15
13
  let(:ex) { StandardError.new("boom") }
16
14
 
17
- it "passes an exception to Honeybadger and Sentry" do
15
+ it "passes an exception to Sentry" do
18
16
  BarsoomUtils::ExceptionNotifier.notify(ex)
19
17
 
20
- expect(Honeybadger).to have_received(:notify).with(ex, context: {})
21
18
  expect(Sentry).to have_received(:capture_exception).with(ex, extra: {})
22
19
  end
23
20
 
24
21
  it "can pass through context info" do
25
22
  BarsoomUtils::ExceptionNotifier.notify(ex, context: { foo: "bar" })
26
23
 
27
- expect(Honeybadger).to have_received(:notify).with(ex, context: { foo: "bar" })
28
24
  expect(Sentry).to have_received(:capture_exception).with(ex, extra: { foo: "bar" })
29
25
  end
30
26
 
@@ -33,74 +29,38 @@ RSpec.describe BarsoomUtils::ExceptionNotifier do
33
29
  BarsoomUtils::ExceptionNotifier.notify({ foo: "bar" })
34
30
  }.to raise_error(/Expected an exception but got:.*foo.*bar/)
35
31
 
36
- expect(Honeybadger).not_to have_received(:notify)
37
32
  expect(Sentry).not_to have_received(:capture_exception)
38
33
  end
39
34
 
40
- it "returns Honeybadger's result" do
41
- allow(Honeybadger).to receive(:notify).and_return(:sentinel)
35
+ it "returns Sentry's result" do
36
+ allow(Sentry).to receive(:capture_exception).and_return(:sentinel)
42
37
 
43
38
  expect(BarsoomUtils::ExceptionNotifier.notify(ex)).to eq(:sentinel)
44
39
  end
45
40
 
46
- context "without Sentry" do
47
- before { hide_const("Sentry") }
41
+ it "raises without Sentry" do
42
+ hide_const("Sentry")
48
43
 
49
- it "still notifies Honeybadger and raises nothing" do
50
- BarsoomUtils::ExceptionNotifier.notify(ex, context: { foo: "bar" })
51
-
52
- expect(Honeybadger).to have_received(:notify).with(ex, context: { foo: "bar" })
53
- end
54
- end
55
-
56
- context "without Honeybadger" do
57
- before { hide_const("Honeybadger") }
58
-
59
- it "still notifies Sentry and raises nothing" do
60
- BarsoomUtils::ExceptionNotifier.notify(ex, context: { foo: "bar" })
61
-
62
- expect(Sentry).to have_received(:capture_exception).with(ex, extra: { foo: "bar" })
63
- end
64
- end
65
-
66
- context "without either notifier" do
67
- before do
68
- hide_const("Honeybadger")
69
- hide_const("Sentry")
70
- end
71
-
72
- it "raises" do
73
- expect {
74
- BarsoomUtils::ExceptionNotifier.notify(ex)
75
- }.to raise_error(/neither Honeybadger nor Sentry/)
76
- end
44
+ expect {
45
+ BarsoomUtils::ExceptionNotifier.notify(ex)
46
+ }.to raise_error(/Sentry is not available/)
77
47
  end
78
48
  end
79
49
 
80
50
  describe ".message" do
81
- it "passes a message to Honeybadger and Sentry" do
51
+ it "passes a message to Sentry" do
82
52
  BarsoomUtils::ExceptionNotifier.message("Boom!")
83
53
 
84
- expect(Honeybadger).to have_received(:notify).with(
85
- error_class: "Boom!",
86
- error_message: "(no message)",
87
- context: {},
88
- )
89
54
  expect(Sentry).to have_received(:capture_message).with("Boom!", extra: {})
90
55
  end
91
56
 
92
57
  it "can take a custom details string" do
93
58
  BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!")
94
59
 
95
- expect(Honeybadger).to have_received(:notify).with(
96
- error_class: "Boom!",
97
- error_message: "Details!",
98
- context: {},
99
- )
100
60
  expect(Sentry).to have_received(:capture_message).with("Boom!: Details!", extra: {})
101
61
  end
102
62
 
103
- it "coerces the message to a string for Sentry" do
63
+ it "coerces the message to a string" do
104
64
  BarsoomUtils::ExceptionNotifier.message(:boom)
105
65
 
106
66
  expect(Sentry).to have_received(:capture_message).with("boom", extra: {})
@@ -109,66 +69,27 @@ RSpec.describe BarsoomUtils::ExceptionNotifier do
109
69
  it "can take a context hash" do
110
70
  BarsoomUtils::ExceptionNotifier.message("Boom!", foo: "bar")
111
71
 
112
- expect(Honeybadger).to have_received(:notify).with(
113
- error_class: "Boom!",
114
- error_message: "(no message)",
115
- context: { foo: "bar" },
116
- )
117
72
  expect(Sentry).to have_received(:capture_message).with("Boom!", extra: { foo: "bar" })
118
73
  end
119
74
 
120
75
  it "can take a custom details string and a context hash" do
121
76
  BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!", foo: "bar")
122
77
 
123
- expect(Honeybadger).to have_received(:notify).with(
124
- error_class: "Boom!",
125
- error_message: "Details!",
126
- context: { foo: "bar" },
127
- )
128
78
  expect(Sentry).to have_received(:capture_message).with("Boom!: Details!", extra: { foo: "bar" })
129
79
  end
130
80
 
131
- it "returns Honeybadger's result" do
132
- allow(Honeybadger).to receive(:notify).and_return(:sentinel)
81
+ it "returns Sentry's result" do
82
+ allow(Sentry).to receive(:capture_message).and_return(:sentinel)
133
83
 
134
84
  expect(BarsoomUtils::ExceptionNotifier.message("Boom!")).to eq(:sentinel)
135
85
  end
136
86
 
137
- context "without Sentry" do
138
- before { hide_const("Sentry") }
87
+ it "raises without Sentry" do
88
+ hide_const("Sentry")
139
89
 
140
- it "still notifies Honeybadger and raises nothing" do
141
- BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!", foo: "bar")
142
-
143
- expect(Honeybadger).to have_received(:notify).with(
144
- error_class: "Boom!",
145
- error_message: "Details!",
146
- context: { foo: "bar" },
147
- )
148
- end
149
- end
150
-
151
- context "without Honeybadger" do
152
- before { hide_const("Honeybadger") }
153
-
154
- it "still notifies Sentry and raises nothing" do
155
- BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!", foo: "bar")
156
-
157
- expect(Sentry).to have_received(:capture_message).with("Boom!: Details!", extra: { foo: "bar" })
158
- end
159
- end
160
-
161
- context "without either notifier" do
162
- before do
163
- hide_const("Honeybadger")
164
- hide_const("Sentry")
165
- end
166
-
167
- it "raises" do
168
- expect {
169
- BarsoomUtils::ExceptionNotifier.message("Boom!")
170
- }.to raise_error(/neither Honeybadger nor Sentry/)
171
- end
90
+ expect {
91
+ BarsoomUtils::ExceptionNotifier.message("Boom!")
92
+ }.to raise_error(/Sentry is not available/)
172
93
  end
173
94
  end
174
95
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barsoom_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.78
4
+ version: 0.3.0.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Skogberg