barsoom_utils 0.2.0.77 → 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: a689d68093a31c8481296dfbf97d19a683637dca75178cb142164b4ce11260a5
4
- data.tar.gz: 8477a0ab5a7700c7bf0897c7a239ec8b48d155f934b81ffaef0c93d75c42faf9
3
+ metadata.gz: d567d7a3ae76f80b86ad642cf590526cb3bc2a2be5b95c94abf8944142a40b15
4
+ data.tar.gz: 0fd5468990225ed9d0faf43d860b6afe2ccb5b24fb5786077cde7054445ea832
5
5
  SHA512:
6
- metadata.gz: bb2a240db5388ccb1634a17fd3820aa3f6dbc161ec953be78ed03ceb111e1832b0d5350adec45bd81eb1ea6133d32507243811ab106e306c1342a6d3bdfea766
7
- data.tar.gz: 7f45fde4df510c8f92895eda05b97300dc6e3f272bb4f9220f50cb516b9748a2d1c89277f60bc1e2d24789354423bc8360d7e6992508f2831fa364943e7feb30
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.77
1
+ 0.3.0.79
@@ -11,12 +11,14 @@ module BarsoomUtils
11
11
  raise "Expected an exception but got: #{exception.inspect}"
12
12
  end
13
13
 
14
- result = Honeybadger.notify(exception, context: context)
15
- Sentry.capture_exception(exception, extra: context) if defined?(Sentry)
16
- result
14
+ ensure_notifier!
15
+
16
+ Sentry.capture_exception(exception, extra: context)
17
17
  end
18
18
 
19
19
  def self.message(message, details_or_context = nil, context_or_nothing = nil)
20
+ ensure_notifier!
21
+
20
22
  if context_or_nothing
21
23
  details = details_or_context
22
24
  context = context_or_nothing
@@ -28,18 +30,17 @@ module BarsoomUtils
28
30
  context = {}
29
31
  end
30
32
 
31
- result = Honeybadger.notify(
32
- error_class: message,
33
- error_message: (details || "(no message)").to_s,
34
- context: context.to_h,
35
- )
33
+ title = details ? "#{message}: #{details}" : message.to_s
34
+ Sentry.capture_message(title, extra: context.to_h)
35
+ end
36
36
 
37
- if defined?(Sentry)
38
- title = details ? "#{message}: #{details}" : message.to_s
39
- Sentry.capture_message(title, extra: context.to_h)
40
- end
37
+ private
38
+
39
+ private_class_method \
40
+ def self.ensure_notifier!
41
+ return if defined?(Sentry)
41
42
 
42
- result
43
+ raise "Cannot notify: Sentry is not available."
43
44
  end
44
45
  end
45
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,51 +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
44
+ expect {
45
+ BarsoomUtils::ExceptionNotifier.notify(ex)
46
+ }.to raise_error(/Sentry is not available/)
54
47
  end
55
48
  end
56
49
 
57
50
  describe ".message" do
58
- it "passes a message to Honeybadger and Sentry" do
51
+ it "passes a message to Sentry" do
59
52
  BarsoomUtils::ExceptionNotifier.message("Boom!")
60
53
 
61
- expect(Honeybadger).to have_received(:notify).with(
62
- error_class: "Boom!",
63
- error_message: "(no message)",
64
- context: {},
65
- )
66
54
  expect(Sentry).to have_received(:capture_message).with("Boom!", extra: {})
67
55
  end
68
56
 
69
57
  it "can take a custom details string" do
70
58
  BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!")
71
59
 
72
- expect(Honeybadger).to have_received(:notify).with(
73
- error_class: "Boom!",
74
- error_message: "Details!",
75
- context: {},
76
- )
77
60
  expect(Sentry).to have_received(:capture_message).with("Boom!: Details!", extra: {})
78
61
  end
79
62
 
80
- it "coerces the message to a string for Sentry" do
63
+ it "coerces the message to a string" do
81
64
  BarsoomUtils::ExceptionNotifier.message(:boom)
82
65
 
83
66
  expect(Sentry).to have_received(:capture_message).with("boom", extra: {})
@@ -86,43 +69,27 @@ RSpec.describe BarsoomUtils::ExceptionNotifier do
86
69
  it "can take a context hash" do
87
70
  BarsoomUtils::ExceptionNotifier.message("Boom!", foo: "bar")
88
71
 
89
- expect(Honeybadger).to have_received(:notify).with(
90
- error_class: "Boom!",
91
- error_message: "(no message)",
92
- context: { foo: "bar" },
93
- )
94
72
  expect(Sentry).to have_received(:capture_message).with("Boom!", extra: { foo: "bar" })
95
73
  end
96
74
 
97
75
  it "can take a custom details string and a context hash" do
98
76
  BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!", foo: "bar")
99
77
 
100
- expect(Honeybadger).to have_received(:notify).with(
101
- error_class: "Boom!",
102
- error_message: "Details!",
103
- context: { foo: "bar" },
104
- )
105
78
  expect(Sentry).to have_received(:capture_message).with("Boom!: Details!", extra: { foo: "bar" })
106
79
  end
107
80
 
108
- it "returns Honeybadger's result" do
109
- 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)
110
83
 
111
84
  expect(BarsoomUtils::ExceptionNotifier.message("Boom!")).to eq(:sentinel)
112
85
  end
113
86
 
114
- context "without Sentry" do
115
- before { hide_const("Sentry") }
87
+ it "raises without Sentry" do
88
+ hide_const("Sentry")
116
89
 
117
- it "still notifies Honeybadger and raises nothing" do
118
- BarsoomUtils::ExceptionNotifier.message("Boom!", "Details!", foo: "bar")
119
-
120
- expect(Honeybadger).to have_received(:notify).with(
121
- error_class: "Boom!",
122
- error_message: "Details!",
123
- context: { foo: "bar" },
124
- )
125
- end
90
+ expect {
91
+ BarsoomUtils::ExceptionNotifier.message("Boom!")
92
+ }.to raise_error(/Sentry is not available/)
126
93
  end
127
94
  end
128
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.77
4
+ version: 0.3.0.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Skogberg