Skip to content

Commit cbb6689

Browse files
committed
add a custom failbot that works
1 parent 7f8b54f commit cbb6689

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

spec/acceptance/acceptance_tests.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,16 @@
180180
expect(response.body).to include("authentication failed")
181181
end
182182
end
183+
184+
describe "boomtown" do
185+
it "sends a POST request to the /webhooks/boomtown endpoint and it explodes" do
186+
payload = {}.to_json
187+
headers = {}
188+
response = http.post("/webhooks/boomtown", payload, headers)
189+
190+
expect(response).to be_a(Net::HTTPInternalServerError)
191+
expect(response.body).to include("Boomtown error occurred")
192+
end
193+
end
183194
end
184195
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
path: /boomtown
2+
handler: Boomtown
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class Boomtown < Hooks::Plugins::Handlers::Base
4+
def call(payload:, headers:, config:)
5+
raise StandardError, "Boomtown error occurred"
6+
end
7+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class Failbot < Hooks::Plugins::Instruments::FailbotBase
4+
def initialize
5+
# just a demo implementation
6+
end
7+
8+
def oh_no
9+
log.error("oh no, something went wrong!")
10+
end
11+
end

spec/acceptance/plugins/lifecycle/request_method_logger.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ class RequestMethodLogger < Hooks::Plugins::Lifecycle
55
def on_request(env)
66
log.debug("on_request called with method: #{env['REQUEST_METHOD']}")
77
end
8+
9+
def on_error(error, env)
10+
log.error("on_error called with error: #{error.message}")
11+
failbot.oh_no
12+
end
813
end

0 commit comments

Comments
 (0)