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
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('../../
|
3
|
+
require File.expand_path('../../spec_helper', __dir__)
|
4
4
|
|
5
5
|
module ExceptionHandling
|
6
|
-
|
6
|
+
describe HoneybadgerCallbacks do
|
7
7
|
|
8
8
|
class TestPoroWithAttribute
|
9
9
|
attr_reader :test_attribute
|
@@ -55,15 +55,15 @@ module ExceptionHandling
|
|
55
55
|
end
|
56
56
|
|
57
57
|
context "register_callbacks" do
|
58
|
-
|
58
|
+
it "store the callbacks in the honeybadger object" do
|
59
59
|
HoneybadgerCallbacks.register_callbacks
|
60
60
|
result = Honeybadger.config.local_variable_filter.call(:variable_name, 'test', [])
|
61
|
-
|
61
|
+
expect(result).to eq('test')
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
context "local_variable_filter" do
|
66
|
-
|
66
|
+
it "not inspect String, Hash, Array, Set, Numeric, TrueClass, FalseClass, NilClass" do
|
67
67
|
[
|
68
68
|
['test', String],
|
69
69
|
[{ a: 1 }, Hash],
|
@@ -75,46 +75,46 @@ module ExceptionHandling
|
|
75
75
|
[nil, NilClass]
|
76
76
|
].each do |object, expected_class|
|
77
77
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, object, [])
|
78
|
-
|
78
|
+
expect(result.is_a?(expected_class)).to be_truthy
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
it "inspect other classes" do
|
83
83
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithAttribute.new, ['password'])
|
84
|
-
|
84
|
+
expect(result).to match(/#<ExceptionHandling::TestPoroWithAttribute:.* @test_attribute="test">/)
|
85
85
|
end
|
86
86
|
|
87
87
|
context "when inspect raises exceptions" do
|
88
|
-
|
88
|
+
it "handle exceptions for objects" do
|
89
89
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestRaiseOnInspect.new, ['password'])
|
90
|
-
|
90
|
+
expect(result).to eq("#<ExceptionHandling::TestRaiseOnInspect [error 'RuntimeError: some error' while calling #inspect]>")
|
91
91
|
end
|
92
92
|
|
93
|
-
|
93
|
+
it "handle exceptions for objects responding to id" do
|
94
94
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestRaiseOnInspectWithId.new, ['password'])
|
95
|
-
|
95
|
+
expect(result).to eq("#<ExceptionHandling::TestRaiseOnInspectWithId @id=123 [error 'RuntimeError: some error' while calling #inspect]>")
|
96
96
|
end
|
97
97
|
|
98
|
-
|
98
|
+
it "handle exceptions for objects responding to to_pk" do
|
99
99
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestRaiseOnInspectWithToPk.new, ['password'])
|
100
|
-
|
100
|
+
expect(result).to eq("#<ExceptionHandling::TestRaiseOnInspectWithToPk @pk=SomeRecord-123 [error 'RuntimeError: some error' while calling #inspect]>")
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
104
|
context "not inspect objects that contain filter keys" do
|
105
|
-
|
105
|
+
it "use to_pk if available, even if id is available" do
|
106
106
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithFilteredAttributePkAndId.new, ['password'])
|
107
|
-
|
107
|
+
expect(result).to match(/#<ExceptionHandling::TestPoroWithFilteredAttributePkAndId @pk=TestPoroWithFilteredAttributePkAndId_1, \[FILTERED\]>/)
|
108
108
|
end
|
109
109
|
|
110
|
-
|
110
|
+
it "use id if to_pk is not available" do
|
111
111
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithFilteredAttributeAndId.new, ['password'])
|
112
|
-
|
112
|
+
expect(result).to match(/#<ExceptionHandling::TestPoroWithFilteredAttributeAndId @id=1, \[FILTERED\]>/)
|
113
113
|
end
|
114
114
|
|
115
|
-
|
115
|
+
it "print the object name if no id or to_pk" do
|
116
116
|
result = HoneybadgerCallbacks.send(:local_variable_filter, :variable_name, TestPoroWithFilteredAttribute.new, ['password'])
|
117
|
-
|
117
|
+
expect(result).to match(/#<ExceptionHandling::TestPoroWithFilteredAttribute \[FILTERED\]>/)
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -1,27 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('../../
|
3
|
+
require File.expand_path('../../spec_helper', __dir__)
|
4
4
|
|
5
5
|
module ExceptionHandling
|
6
|
-
|
6
|
+
describe LogErrorStub do
|
7
7
|
|
8
8
|
include LogErrorStub
|
9
9
|
|
10
10
|
context "while running tests" do
|
11
|
-
|
11
|
+
before do
|
12
12
|
setup_log_error_stub
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
after do
|
16
16
|
teardown_log_error_stub
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it "raise an error when log_error and log_warning are called" do
|
20
20
|
begin
|
21
21
|
ExceptionHandling.log_error("Something happened")
|
22
22
|
flunk
|
23
23
|
rescue Exception => ex # LogErrorStub::UnexpectedExceptionLogged => ex
|
24
|
-
|
24
|
+
expect(ex.to_s.starts_with?("StandardError: Something happened")).to be_truthy
|
25
25
|
end
|
26
26
|
|
27
27
|
begin
|
@@ -31,16 +31,16 @@ module ExceptionHandling
|
|
31
31
|
begin
|
32
32
|
ExceptionHandling.log_error(ex)
|
33
33
|
rescue LogErrorStub::UnexpectedExceptionLogged => ex
|
34
|
-
|
34
|
+
expect(ex.to_s.starts_with?("RaisedError: This should raise")).to be_truthy
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
it "allow for the regex specification of an expected exception to be ignored" do
|
40
40
|
exception_pattern = /StandardError: This is a test error/
|
41
|
-
|
41
|
+
expect(exception_whitelist).to be_nil # test that exception expectations are cleared
|
42
42
|
expects_exception(exception_pattern)
|
43
|
-
|
43
|
+
expect(exception_whitelist[0][0]).to eq(exception_pattern)
|
44
44
|
begin
|
45
45
|
ExceptionHandling.log_error("This is a test error")
|
46
46
|
rescue StandardError
|
@@ -48,11 +48,11 @@ module ExceptionHandling
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
it "allow for the string specification of an expected exception to be ignored" do
|
52
52
|
exception_pattern = "StandardError: This is a test error"
|
53
|
-
|
53
|
+
expect(exception_whitelist).to be_nil # test that exception expectations are cleared
|
54
54
|
expects_exception(exception_pattern)
|
55
|
-
|
55
|
+
expect(exception_whitelist[0][0]).to eq(exception_pattern)
|
56
56
|
begin
|
57
57
|
ExceptionHandling.log_error("This is a test error")
|
58
58
|
rescue StandardError
|
@@ -60,9 +60,9 @@ module ExceptionHandling
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
it "allow multiple errors to be ignored" do
|
64
64
|
class IgnoredError < StandardError; end
|
65
|
-
|
65
|
+
expect(exception_whitelist).to be_nil # test that exception expectations are cleared
|
66
66
|
expects_exception(/StandardError: This is a test error/)
|
67
67
|
expects_exception(/IgnoredError: This should be ignored/)
|
68
68
|
ExceptionHandling.log_error("This is a test error")
|
@@ -73,7 +73,7 @@ module ExceptionHandling
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
|
76
|
+
it "expect exception twice if declared twice" do
|
77
77
|
expects_exception(/StandardError: ERROR: I love lamp/)
|
78
78
|
expects_exception(/StandardError: ERROR: I love lamp/)
|
79
79
|
ExceptionHandling.log_error("ERROR: I love lamp")
|
@@ -82,23 +82,39 @@ module ExceptionHandling
|
|
82
82
|
end
|
83
83
|
|
84
84
|
context "teardown_log_error_stub" do
|
85
|
-
|
85
|
+
before do
|
86
|
+
RSpec.configure do |config|
|
87
|
+
config.mock_with :rspec do |mocks|
|
88
|
+
mocks.verify_partial_doubles = false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
after do
|
94
|
+
RSpec.configure do |config|
|
95
|
+
config.mock_with :rspec do |mocks|
|
96
|
+
mocks.verify_partial_doubles = true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
it "support MiniTest framework for adding a failure" do
|
86
102
|
expects_exception(/foo/)
|
87
103
|
|
88
|
-
|
104
|
+
expect(self).to receive(:is_mini_test?) { true }
|
89
105
|
|
90
|
-
|
106
|
+
expect(self).to receive(:flunk).with("log_error expected 1 times with pattern: 'foo' found 0")
|
91
107
|
teardown_log_error_stub
|
92
108
|
|
93
109
|
self.exception_whitelist = nil
|
94
110
|
end
|
95
111
|
|
96
|
-
|
112
|
+
it "support Test::Unit framework for adding a failure" do
|
97
113
|
expects_exception(/foo/)
|
98
114
|
|
99
|
-
|
115
|
+
expect(self).to receive(:is_mini_test?) { false }
|
100
116
|
|
101
|
-
|
117
|
+
expect(self).to receive(:add_failure).with("log_error expected 1 times with pattern: 'foo' found 0")
|
102
118
|
teardown_log_error_stub
|
103
119
|
|
104
120
|
self.exception_whitelist = nil
|
data/{test/unit/exception_handling/mailer_test.rb → spec/unit/exception_handling/mailer_spec.rb}
RENAMED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('../../
|
3
|
+
require File.expand_path('../../spec_helper', __dir__)
|
4
|
+
require 'rails-dom-testing'
|
4
5
|
|
5
6
|
module ExceptionHandling
|
6
|
-
|
7
|
+
describe Mailer do
|
7
8
|
|
8
9
|
include ::Rails::Dom::Testing::Assertions::SelectorAssertions
|
9
|
-
tests ExceptionHandling::Mailer
|
10
10
|
|
11
11
|
def dont_stub_log_error
|
12
12
|
true
|
13
13
|
end
|
14
14
|
|
15
15
|
context "ExceptionHandling::Mailer" do
|
16
|
-
|
16
|
+
before do
|
17
17
|
ExceptionHandling.email_environment = 'Test'
|
18
18
|
ExceptionHandling.sender_address = %("Test Exception Mailer" <null_exception@invoca.com>)
|
19
19
|
ExceptionHandling.exception_recipients = ['test_exception@invoca.com']
|
@@ -21,22 +21,22 @@ module ExceptionHandling
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context "log_parser_exception_notification" do
|
24
|
-
|
24
|
+
it "send with string" do
|
25
25
|
result = ExceptionHandling::Mailer.log_parser_exception_notification("This is my fake error", "My Fake Subj").deliver_now
|
26
|
-
|
27
|
-
|
26
|
+
expect(result.subject).to eq("Test exception: My Fake Subj: This is my fake error")
|
27
|
+
expect(result.body.to_s).to match(/This is my fake error/)
|
28
28
|
assert_emails 1
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
context "escalation_notification" do
|
33
|
-
|
33
|
+
before do
|
34
34
|
def document_root_element
|
35
35
|
@body_html.root
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
it "send all the information" do
|
40
40
|
ExceptionHandling.email_environment = 'Staging Full'
|
41
41
|
ExceptionHandling.server_name = 'test-fe3'
|
42
42
|
|
@@ -46,8 +46,8 @@ module ExceptionHandling
|
|
46
46
|
result = ActionMailer::Base.deliveries.last
|
47
47
|
@body_html = Nokogiri::HTML(result.body.to_s)
|
48
48
|
assert_equal_with_diff ['test_escalation@invoca.com'], result.to
|
49
|
-
|
50
|
-
|
49
|
+
expect(result[:from].formatted).to eq(["Test Escalation Mailer <null_escalation@invoca.com>"])
|
50
|
+
expect(result.subject).to eq("Staging Full Escalation: Your Favorite <b>Feature<b> Failed")
|
51
51
|
assert_select "title", "Exception Escalation"
|
52
52
|
assert_select "html" do
|
53
53
|
assert_select "body br", { count: 4 }, result.body.to_s # plus 1 for the multiline summary
|
@@ -60,13 +60,13 @@ module ExceptionHandling
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
it "use defaults for missing fields" do
|
64
64
|
result = ExceptionHandling::Mailer.escalation_notification("Your Favorite Feature Failed", error_string: "It failed because of an error\n More Info")
|
65
65
|
@body_html = Nokogiri::HTML(result.body.to_s)
|
66
66
|
|
67
67
|
assert_equal_with_diff ['test_escalation@invoca.com'], result.to
|
68
|
-
|
69
|
-
|
68
|
+
expect(result.from).to eq(["null_escalation@invoca.com"])
|
69
|
+
expect(result.subject).to eq('Test Escalation: Your Favorite Feature Failed')
|
70
70
|
assert_select "html" do
|
71
71
|
assert_select "body i", true, result.body.to_s do |is|
|
72
72
|
assert_select is, "i", 'no error #'
|
@@ -75,11 +75,11 @@ module ExceptionHandling
|
|
75
75
|
end
|
76
76
|
|
77
77
|
context "ExceptionHandling.escalate_to_production_support" do
|
78
|
-
|
78
|
+
before do
|
79
79
|
Time.now_override = Time.parse('1986-5-21 4:17 am UTC')
|
80
80
|
end
|
81
81
|
|
82
|
-
|
82
|
+
it "notify production support" do
|
83
83
|
subject = "Runtime Error found!"
|
84
84
|
exception = RuntimeError.new("Test")
|
85
85
|
recipients = ["prodsupport@example.com"]
|
@@ -87,7 +87,7 @@ module ExceptionHandling
|
|
87
87
|
ExceptionHandling.production_support_recipients = recipients
|
88
88
|
ExceptionHandling.last_exception_timestamp = Time.now.to_i
|
89
89
|
|
90
|
-
|
90
|
+
expect(ExceptionHandling).to receive(:escalate).with(subject, exception, Time.now.to_i, recipients)
|
91
91
|
ExceptionHandling.escalate_to_production_support(exception, subject)
|
92
92
|
end
|
93
93
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../../spec_helper', __dir__)
|
4
|
+
|
5
|
+
require "exception_handling/testing"
|
6
|
+
require_relative '../../helpers/exception_helpers.rb'
|
7
|
+
|
8
|
+
module ExceptionHandling
|
9
|
+
describe Methods do
|
10
|
+
include ExceptionHelpers
|
11
|
+
|
12
|
+
def dont_stub_log_error
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
context "ExceptionHandling.Methods" do
|
17
|
+
before do
|
18
|
+
@controller = Testing::ControllerStub.new
|
19
|
+
ExceptionHandling.stub_handler = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "set the around filter" do
|
23
|
+
expect(Testing::ControllerStub.around_filter_method).to eq(:set_current_controller)
|
24
|
+
expect(ExceptionHandling.current_controller).to be_nil
|
25
|
+
@controller.simulate_around_filter do
|
26
|
+
expect(ExceptionHandling.current_controller).to eq(@controller)
|
27
|
+
end
|
28
|
+
expect(ExceptionHandling.current_controller).to be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "use the current_controller when available" do
|
32
|
+
capture_notifications
|
33
|
+
|
34
|
+
expect(ExceptionHandling.logger).to receive(:fatal).with(/blah/, anything).at_least(:once)
|
35
|
+
@controller.simulate_around_filter do
|
36
|
+
ExceptionHandling.log_error(ArgumentError.new("blah"))
|
37
|
+
expect(sent_notifications.size).to eq(1)
|
38
|
+
expect(/#{Regexp.new(Regexp.escape(@controller.request.request_uri))}/).to match(sent_notifications.last.enhanced_data['request'].to_s)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "report long running controller action" do
|
43
|
+
expect(@controller.send(:long_controller_action_timeout)).to eq(2)
|
44
|
+
expect(ExceptionHandling).to receive(:log_error).with(/Long controller action detected in #{@controller.class.name.split("::").last}::test_action/, anything, anything)
|
45
|
+
@controller.simulate_around_filter do
|
46
|
+
sleep(3)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "not report long running controller actions if it is less than the timeout" do
|
51
|
+
expect(@controller.send(:long_controller_action_timeout)).to eq(2)
|
52
|
+
allow(ExceptionHandling).to receive(:log_error).and_return("Should not timeout")
|
53
|
+
@controller.simulate_around_filter do
|
54
|
+
sleep(1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "default long running controller action(300/30 for test/prod)" do
|
59
|
+
class DummyController
|
60
|
+
include ExceptionHandling::Methods
|
61
|
+
end
|
62
|
+
|
63
|
+
controller = DummyController.new
|
64
|
+
|
65
|
+
Rails.env = 'production'
|
66
|
+
expect(controller.send(:long_controller_action_timeout)).to eq(30)
|
67
|
+
|
68
|
+
Rails.env = 'test'
|
69
|
+
expect(controller.send(:long_controller_action_timeout)).to eq(300)
|
70
|
+
end
|
71
|
+
|
72
|
+
context "#log_warning" do
|
73
|
+
it "be available to the controller" do
|
74
|
+
expect(@controller.methods.include?(:log_warning)).to eq(true)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "call ExceptionHandling#log_warning" do
|
78
|
+
expect(ExceptionHandling).to receive(:log_warning).with("Hi mom")
|
79
|
+
@controller.send(:log_warning, "Hi mom")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../../spec_helper', __dir__)
|
4
|
+
|
5
|
+
module ExceptionHandling
|
6
|
+
describe Sensu do
|
7
|
+
context "#generate_event" do
|
8
|
+
it "create an event" do
|
9
|
+
expect(ExceptionHandling::Sensu).to receive(:send_event).with(name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1)
|
10
|
+
|
11
|
+
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "add the sensu prefix" do
|
15
|
+
ExceptionHandling.sensu_prefix = "cnn_"
|
16
|
+
|
17
|
+
expect(ExceptionHandling::Sensu).to receive(:send_event).with(name: "cnn_world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1)
|
18
|
+
|
19
|
+
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye")
|
20
|
+
end
|
21
|
+
|
22
|
+
it "allow the level to be set to critical" do
|
23
|
+
expect(ExceptionHandling::Sensu).to receive(:send_event).with(name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 2)
|
24
|
+
|
25
|
+
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye", :critical)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "error if an invalid level is supplied" do
|
29
|
+
expect(ExceptionHandling::Sensu).to_not receive(:send_event)
|
30
|
+
|
31
|
+
expect do
|
32
|
+
ExceptionHandling::Sensu.generate_event("world_is_ending", "stick head between knees and kiss ass goodbye", :hair_on_fire)
|
33
|
+
end.to raise_exception(RuntimeError, /Invalid alert level/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "#send_event" do
|
38
|
+
before do
|
39
|
+
@event = { name: "world_is_ending", output: "stick head between knees and kiss ass goodbye", status: 1 }
|
40
|
+
@socket = SocketStub.new
|
41
|
+
end
|
42
|
+
|
43
|
+
it "send event json to sensu client" do
|
44
|
+
expect_any_instance_of(Addrinfo).to receive(:connect).with(any_args) { @socket }
|
45
|
+
ExceptionHandling::Sensu.send_event(@event)
|
46
|
+
|
47
|
+
expect(@socket.sent.first).to eq(@event.to_json)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|