exception_handling 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.jenkins/Jenkinsfile +24 -8
- data/.rspec +3 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile +4 -4
- data/Gemfile.lock +29 -19
- data/Rakefile +7 -6
- data/lib/exception_handling/exception_info.rb +3 -6
- data/lib/exception_handling/log_stub_error.rb +2 -1
- data/lib/exception_handling/version.rb +1 -1
- data/{test → spec}/helpers/controller_helpers.rb +0 -0
- data/{test → spec}/helpers/exception_helpers.rb +2 -2
- data/{test → spec}/rake_test_warning_false.rb +0 -0
- data/{test/test_helper.rb → spec/spec_helper.rb} +50 -39
- data/spec/unit/exception_handling/exception_catalog_spec.rb +85 -0
- data/spec/unit/exception_handling/exception_description_spec.rb +82 -0
- data/{test/unit/exception_handling/exception_info_test.rb → spec/unit/exception_handling/exception_info_spec.rb} +118 -99
- data/{test/unit/exception_handling/honeybadger_callbacks_test.rb → spec/unit/exception_handling/honeybadger_callbacks_spec.rb} +20 -20
- data/{test/unit/exception_handling/log_error_stub_test.rb → spec/unit/exception_handling/log_error_stub_spec.rb} +38 -22
- data/{test/unit/exception_handling/mailer_test.rb → spec/unit/exception_handling/mailer_spec.rb} +17 -17
- data/spec/unit/exception_handling/methods_spec.rb +84 -0
- data/spec/unit/exception_handling/sensu_spec.rb +51 -0
- data/{test/unit/exception_handling_test.rb → spec/unit/exception_handling_spec.rb} +325 -329
- metadata +29 -28
- data/test/unit/exception_handling/exception_catalog_test.rb +0 -85
- data/test/unit/exception_handling/exception_description_test.rb +0 -82
- data/test/unit/exception_handling/methods_test.rb +0 -84
- data/test/unit/exception_handling/sensu_test.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e775cff5b73e955140fcc3a5492564e565567e8de147424da3602b83ad2e3b55
|
4
|
+
data.tar.gz: 35fa446e469e356ae600c5b24860ec8ff73dda25a72df59d5954be0748aac6bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3486a507210596be078ae1953105859d9d2e556b5794f9e1b01bbee21b34e6cd04be115429548a02cce1c6fec80ea680f990ba8b83d07c9594fed5c7de712d5
|
7
|
+
data.tar.gz: e19c845b8d8332f5118c0668c4520cabf00bf88c94117111ee2801d5320f2af2cc620224d79e3dc2e4daef62c4c7cb4115e3cc010cf56e8292cf9dcfef49f974
|
data/.gitignore
CHANGED
data/.jenkins/Jenkinsfile
CHANGED
@@ -36,42 +36,58 @@ pipeline {
|
|
36
36
|
stage('Appraisals') {
|
37
37
|
parallel {
|
38
38
|
stage('Current') {
|
39
|
+
environment {
|
40
|
+
JUNIT_OUTPUT = 'spec/reports/current'
|
41
|
+
}
|
42
|
+
|
39
43
|
steps {
|
40
|
-
sh
|
44
|
+
sh "bundle exec rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
41
45
|
}
|
42
46
|
|
43
47
|
post {
|
44
|
-
always { junit
|
48
|
+
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
45
49
|
}
|
46
50
|
}
|
47
51
|
|
48
52
|
stage('Rails 4') {
|
53
|
+
environment {
|
54
|
+
JUNIT_OUTPUT = 'spec/reports/rails-4'
|
55
|
+
}
|
56
|
+
|
49
57
|
steps {
|
50
|
-
sh
|
58
|
+
sh "bundle exec appraisal rails-4 rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
51
59
|
}
|
52
60
|
|
53
61
|
post {
|
54
|
-
always { junit
|
62
|
+
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
55
63
|
}
|
56
64
|
}
|
57
65
|
|
58
66
|
stage('Rails 5') {
|
67
|
+
environment {
|
68
|
+
JUNIT_OUTPUT = 'spec/reports/rails-5'
|
69
|
+
}
|
70
|
+
|
59
71
|
steps {
|
60
|
-
sh
|
72
|
+
sh "bundle exec appraisal rails-5 rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
61
73
|
}
|
62
74
|
|
63
75
|
post {
|
64
|
-
always { junit
|
76
|
+
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
65
77
|
}
|
66
78
|
}
|
67
79
|
|
68
80
|
stage('Rails 6') {
|
81
|
+
environment {
|
82
|
+
JUNIT_OUTPUT = 'spec/reports/rails-6'
|
83
|
+
}
|
84
|
+
|
69
85
|
steps {
|
70
|
-
sh
|
86
|
+
sh "bundle exec appraisal rails-6 rspec --format RspecJunitFormatter --out ${JUNIT_OUTPUT}/rspec.xml"
|
71
87
|
}
|
72
88
|
|
73
89
|
post {
|
74
|
-
always { junit
|
90
|
+
always { junit "${JUNIT_OUTPUT}/*.xml" }
|
75
91
|
}
|
76
92
|
}
|
77
93
|
}
|
data/.rspec
ADDED
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,11 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
5
5
|
Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [2.6.
|
7
|
+
## [2.6.1] - 2020-10-14
|
8
|
+
### Fixed
|
9
|
+
- Fixed honeybadger_context_data to always merge `current_context_for_thread`, even if `log_context:` is passed as `nil`.
|
10
|
+
|
11
|
+
## [2.6.0] - 2020-08-26
|
8
12
|
### Changed
|
9
13
|
- Calling `log_warning` will now log with Severity::WARNING rather than FATAL.
|
10
14
|
- Reordered the logging to put the exception class next to the message.
|
@@ -42,6 +46,7 @@ Note: this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0
|
|
42
46
|
### Changed
|
43
47
|
- No longer depends on hobo_support. Uses invoca-utils 0.3 instead.
|
44
48
|
|
49
|
+
[2.6.1]: https://github.com/Invoca/exception_handling/compare/v2.6.0...v2.6.1
|
45
50
|
[2.6.0]: https://github.com/Invoca/exception_handling/compare/v2.5.0...v2.6.0
|
46
51
|
[2.5.0]: https://github.com/Invoca/exception_handling/compare/v2.4.4...v2.5.0
|
47
52
|
[2.4.4]: https://github.com/Invoca/exception_handling/compare/v2.4.3...v2.4.4
|
data/Gemfile
CHANGED
@@ -6,10 +6,10 @@ gemspec
|
|
6
6
|
|
7
7
|
gem 'appraisal', '~> 2.2'
|
8
8
|
gem 'honeybadger', '3.3.1-1', git: 'git@github.com:Invoca/honeybadger-ruby', ref: 'bb5f2b8a86e4147c38a6270d39ad610fab4dd5e6'
|
9
|
-
gem "minitest"
|
10
|
-
gem "minitest-reporters"
|
11
9
|
gem 'pry'
|
10
|
+
gem 'pry-byebug'
|
12
11
|
gem 'rake'
|
13
|
-
gem '
|
12
|
+
gem 'rspec'
|
13
|
+
gem 'rspec_junit_formatter'
|
14
14
|
gem 'rubocop'
|
15
|
-
gem '
|
15
|
+
gem 'test-unit'
|
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
exception_handling (2.6.
|
11
|
+
exception_handling (2.6.1)
|
12
12
|
actionmailer (>= 4.2, < 7.0)
|
13
13
|
actionpack (>= 4.2, < 7.0)
|
14
14
|
activesupport (>= 4.2, < 7.0)
|
@@ -46,19 +46,20 @@ GEM
|
|
46
46
|
minitest (~> 5.1)
|
47
47
|
thread_safe (~> 0.3, >= 0.3.4)
|
48
48
|
tzinfo (~> 1.1)
|
49
|
-
ansi (1.5.0)
|
50
49
|
appraisal (2.2.0)
|
51
50
|
bundler
|
52
51
|
rake
|
53
52
|
thor (>= 0.14.0)
|
54
53
|
ast (2.4.0)
|
55
54
|
builder (3.2.3)
|
55
|
+
byebug (11.1.3)
|
56
56
|
coderay (1.1.2)
|
57
57
|
concurrent-ruby (1.1.5)
|
58
|
-
contextual_logger (0.
|
58
|
+
contextual_logger (0.10.0)
|
59
59
|
activesupport
|
60
60
|
json
|
61
61
|
crass (1.0.6)
|
62
|
+
diff-lcs (1.4.4)
|
62
63
|
erubis (2.7.0)
|
63
64
|
eventmachine (1.2.7)
|
64
65
|
globalid (0.4.2)
|
@@ -77,19 +78,18 @@ GEM
|
|
77
78
|
mini_mime (1.0.2)
|
78
79
|
mini_portile2 (2.4.0)
|
79
80
|
minitest (5.11.3)
|
80
|
-
minitest-reporters (1.0.20)
|
81
|
-
ansi
|
82
|
-
builder
|
83
|
-
minitest (>= 5.0)
|
84
|
-
ruby-progressbar
|
85
81
|
nokogiri (1.10.10)
|
86
82
|
mini_portile2 (~> 2.4.0)
|
87
83
|
parallel (1.17.0)
|
88
84
|
parser (2.6.3.0)
|
89
85
|
ast (~> 2.4.0)
|
86
|
+
power_assert (1.2.0)
|
90
87
|
pry (0.12.2)
|
91
88
|
coderay (~> 1.1.0)
|
92
89
|
method_source (~> 0.9.0)
|
90
|
+
pry-byebug (3.8.0)
|
91
|
+
byebug (~> 11.0)
|
92
|
+
pry (~> 0.10)
|
93
93
|
rack (1.6.13)
|
94
94
|
rack-test (0.6.3)
|
95
95
|
rack (>= 1.0)
|
@@ -103,7 +103,21 @@ GEM
|
|
103
103
|
loofah (~> 2.3)
|
104
104
|
rainbow (3.0.0)
|
105
105
|
rake (13.0.1)
|
106
|
-
|
106
|
+
rspec (3.9.0)
|
107
|
+
rspec-core (~> 3.9.0)
|
108
|
+
rspec-expectations (~> 3.9.0)
|
109
|
+
rspec-mocks (~> 3.9.0)
|
110
|
+
rspec-core (3.9.2)
|
111
|
+
rspec-support (~> 3.9.3)
|
112
|
+
rspec-expectations (3.9.2)
|
113
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
114
|
+
rspec-support (~> 3.9.0)
|
115
|
+
rspec-mocks (3.9.1)
|
116
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
117
|
+
rspec-support (~> 3.9.0)
|
118
|
+
rspec-support (3.9.3)
|
119
|
+
rspec_junit_formatter (0.4.1)
|
120
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
107
121
|
rubocop (0.74.0)
|
108
122
|
jaro_winkler (~> 1.5.1)
|
109
123
|
parallel (~> 1.10)
|
@@ -112,12 +126,8 @@ GEM
|
|
112
126
|
ruby-progressbar (~> 1.7)
|
113
127
|
unicode-display_width (>= 1.4.0, < 1.7)
|
114
128
|
ruby-progressbar (1.10.1)
|
115
|
-
|
116
|
-
|
117
|
-
shoulda-matchers (~> 3.0)
|
118
|
-
shoulda-context (1.2.2)
|
119
|
-
shoulda-matchers (3.1.3)
|
120
|
-
activesupport (>= 4.0.0)
|
129
|
+
test-unit (3.3.6)
|
130
|
+
power_assert
|
121
131
|
thor (1.0.1)
|
122
132
|
thread_safe (0.3.6)
|
123
133
|
tzinfo (1.2.5)
|
@@ -131,13 +141,13 @@ DEPENDENCIES
|
|
131
141
|
appraisal (~> 2.2)
|
132
142
|
exception_handling!
|
133
143
|
honeybadger (= 3.3.1.pre.1)!
|
134
|
-
minitest
|
135
|
-
minitest-reporters
|
136
144
|
pry
|
145
|
+
pry-byebug
|
137
146
|
rake
|
138
|
-
|
147
|
+
rspec
|
148
|
+
rspec_junit_formatter
|
139
149
|
rubocop
|
140
|
-
|
150
|
+
test-unit
|
141
151
|
|
142
152
|
BUNDLED WITH
|
143
153
|
1.17.3
|
data/Rakefile
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require "bundler/gem_tasks"
|
5
4
|
require 'rake/testtask'
|
5
|
+
require "bundler/gem_tasks"
|
6
6
|
|
7
|
-
require_relative '
|
8
|
-
|
9
|
-
task default: :test
|
7
|
+
require_relative 'spec/rake_test_warning_false'
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
desc "run rspec unit tests"
|
10
|
+
begin
|
11
|
+
require 'rspec/core/rake_task'
|
12
|
+
RSpec::Core::RakeTask.new(:rspec)
|
13
13
|
end
|
14
14
|
|
15
|
+
task default: :rspec
|
@@ -57,9 +57,8 @@ module ExceptionHandling
|
|
57
57
|
@timestamp = timestamp
|
58
58
|
@controller = controller || controller_from_context(exception_context)
|
59
59
|
@data_callback = data_callback
|
60
|
-
|
61
|
-
|
62
|
-
end
|
60
|
+
# merge into the surrounding context just like ContextualLogger does when logging
|
61
|
+
@merged_log_context = ExceptionHandling.logger.current_context_for_thread.deep_merge(log_context || {})
|
63
62
|
end
|
64
63
|
|
65
64
|
def data
|
@@ -273,13 +272,11 @@ module ExceptionHandling
|
|
273
272
|
data[:exception_context] = deep_clean_hash(@exception_context) if @exception_context.present?
|
274
273
|
data[:log_context] = @merged_log_context
|
275
274
|
unstringify_sections(data)
|
276
|
-
|
275
|
+
HONEYBADGER_CONTEXT_SECTIONS.each_with_object({}) do |section, context|
|
277
276
|
if data[section].present?
|
278
277
|
context[section] = data[section]
|
279
278
|
end
|
280
|
-
context
|
281
279
|
end
|
282
|
-
context_data
|
283
280
|
end
|
284
281
|
end
|
285
282
|
end
|
File without changes
|
@@ -7,7 +7,7 @@ module ExceptionHelpers
|
|
7
7
|
|
8
8
|
def exception_with_nil_message
|
9
9
|
exception_with_nil_message = RuntimeError.new(nil)
|
10
|
-
|
10
|
+
allow(exception_with_nil_message).to receive(:message).and_return(nil)
|
11
11
|
exception_with_nil_message
|
12
12
|
end
|
13
13
|
|
@@ -15,6 +15,6 @@ module ExceptionHelpers
|
|
15
15
|
|
16
16
|
def capture_notifications
|
17
17
|
@sent_notifications = []
|
18
|
-
|
18
|
+
allow(ExceptionHandling).to receive(:send_exception_to_honeybadger).with(anything) { |exception_info| @sent_notifications << exception_info }
|
19
19
|
end
|
20
20
|
end
|
File without changes
|
@@ -1,17 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require 'action_mailer'
|
7
|
-
require 'action_dispatch'
|
8
|
-
require 'shoulda'
|
9
|
-
require 'rr'
|
10
|
-
require 'minitest/autorun'
|
11
|
-
require "minitest/reporters"
|
12
|
-
|
13
|
-
junit_ouptut_dir = ENV["JUNIT_OUTPUT_DIR"].presence || "test/reports"
|
14
|
-
Minitest::Reporters.use!([Minitest::Reporters::DefaultReporter.new, Minitest::Reporters::JUnitReporter.new(junit_ouptut_dir)])
|
3
|
+
require 'rspec'
|
4
|
+
require 'rspec/mocks'
|
5
|
+
require 'rspec_junit_formatter'
|
15
6
|
|
16
7
|
require 'pry'
|
17
8
|
require 'honeybadger'
|
@@ -20,8 +11,6 @@ require 'contextual_logger'
|
|
20
11
|
require 'exception_handling'
|
21
12
|
require 'exception_handling/testing'
|
22
13
|
|
23
|
-
ActiveSupport::TestCase.test_order = :sorted
|
24
|
-
|
25
14
|
class LoggerStub
|
26
15
|
include ContextualLogger::LoggerMixin
|
27
16
|
attr_accessor :logged, :level
|
@@ -87,27 +76,17 @@ end
|
|
87
76
|
|
88
77
|
ActionMailer::Base.delivery_method = :test
|
89
78
|
|
90
|
-
_ = ActiveSupport
|
91
|
-
_ = ActiveSupport::TestCase
|
92
79
|
|
93
|
-
|
94
|
-
|
80
|
+
module TestHelper
|
81
|
+
@constant_overrides = []
|
82
|
+
class << self
|
83
|
+
attr_accessor :constant_overrides
|
84
|
+
end
|
95
85
|
|
96
|
-
setup do
|
97
|
-
unless @@constant_overrides.nil? || @@constant_overrides.empty?
|
98
|
-
raise "Uh-oh! constant_overrides left over: #{@@constant_overrides.inspect}"
|
99
|
-
end
|
100
86
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
attr_writer :env
|
105
|
-
|
106
|
-
def env
|
107
|
-
@env ||= 'test'
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
87
|
+
def setup_constant_overrides
|
88
|
+
unless TestHelper.constant_overrides.nil? || TestHelper.constant_overrides.empty?
|
89
|
+
raise "Uh-oh! constant_overrides left over: #{TestHelper.constant_overrides.inspect}"
|
111
90
|
end
|
112
91
|
|
113
92
|
Time.now_override = nil
|
@@ -127,8 +106,8 @@ class ActiveSupport::TestCase
|
|
127
106
|
ExceptionHandling.sensu_prefix = ""
|
128
107
|
end
|
129
108
|
|
130
|
-
|
131
|
-
|
109
|
+
def teardown_constant_overrides
|
110
|
+
TestHelper.constant_overrides&.reverse&.each do |parent_module, k, v|
|
132
111
|
ExceptionHandling.ensure_safe "constant cleanup #{k.inspect}, #{parent_module}(#{parent_module.class})::#{v.inspect}(#{v.class})" do
|
133
112
|
silence_warnings do
|
134
113
|
if v == :never_defined
|
@@ -139,7 +118,7 @@ class ActiveSupport::TestCase
|
|
139
118
|
end
|
140
119
|
end
|
141
120
|
end
|
142
|
-
|
121
|
+
TestHelper.constant_overrides = []
|
143
122
|
end
|
144
123
|
|
145
124
|
def set_test_const(const_name, value)
|
@@ -159,7 +138,7 @@ class ActiveSupport::TestCase
|
|
159
138
|
end
|
160
139
|
end
|
161
140
|
|
162
|
-
|
141
|
+
TestHelper.constant_overrides << [final_parent_module, final_const_name, original_value]
|
163
142
|
|
164
143
|
silence_warnings { final_parent_module.const_set(final_const_name, value) }
|
165
144
|
end
|
@@ -171,15 +150,15 @@ class ActiveSupport::TestCase
|
|
171
150
|
else
|
172
151
|
original_count = 0
|
173
152
|
end
|
174
|
-
|
153
|
+
expect(ActionMailer::Base.deliveries.size - original_count).to eq(expected), "wrong number of emails#{': ' + message.to_s if message}"
|
175
154
|
end
|
176
155
|
end
|
177
156
|
|
178
157
|
def assert_equal_with_diff(arg1, arg2, msg = '')
|
179
158
|
if arg1 == arg2
|
180
|
-
|
159
|
+
expect(true).to be_truthy # To keep the assertion count accurate
|
181
160
|
else
|
182
|
-
|
161
|
+
expect(arg1).to eq(arg2), "#{msg}\n#{Diff.compare(arg1, arg2)}"
|
183
162
|
end
|
184
163
|
end
|
185
164
|
|
@@ -210,3 +189,35 @@ class Time
|
|
210
189
|
end
|
211
190
|
end
|
212
191
|
end
|
192
|
+
|
193
|
+
RSpec.configure do |config|
|
194
|
+
config.add_formatter(RspecJunitFormatter, 'spec/reports/rspec.xml')
|
195
|
+
config.include TestHelper
|
196
|
+
|
197
|
+
config.before(:each) do
|
198
|
+
setup_constant_overrides
|
199
|
+
unless defined?(Rails) && defined?(Rails.env)
|
200
|
+
module Rails
|
201
|
+
class << self
|
202
|
+
attr_writer :env
|
203
|
+
|
204
|
+
def env
|
205
|
+
@env ||= 'test'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
config.after(:each) do
|
213
|
+
teardown_constant_overrides
|
214
|
+
end
|
215
|
+
|
216
|
+
config.mock_with :rspec do |mocks|
|
217
|
+
mocks.verify_partial_doubles = true
|
218
|
+
end
|
219
|
+
|
220
|
+
config.expect_with(:rspec, :test_unit)
|
221
|
+
|
222
|
+
RSpec::Support::ObjectFormatter.default_instance.max_formatted_output_length = 2_000
|
223
|
+
end
|