File tree Expand file tree Collapse file tree 2 files changed +7
-24
lines changed
Expand file tree Collapse file tree 2 files changed +7
-24
lines changed Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33describe Hooks ::Log do
4+ after do
5+ # Clean up any mock loggers to avoid interference with other tests
6+ described_class . instance = nil
7+ end
8+
49 describe ".instance" do
510 it "has an accessor for the logger instance" do
611 expect ( described_class ) . to respond_to ( :instance )
Original file line number Diff line number Diff line change 77 let ( :config ) { { endpoint : "test" , auth : { type : "hmac" } } }
88
99 before do
10- # Reset any mocked log instances to avoid interference
11- allow ( handler ) . to receive ( :log ) . and_call_original
10+ # Provide a null logger to avoid nil errors while allowing logging to work
11+ Hooks :: Log . instance = Logger . new ( StringIO . new )
1212 end
1313
1414 describe "#call" do
8686 expect ( response [ :timestamp ] ) . to eq ( TIME_MOCK )
8787 end
8888 end
89-
90- context "logging behavior" do
91- it "logs handler invocation" do
92- fresh_handler = described_class . new
93- log_double = instance_double ( Logger )
94- allow ( fresh_handler ) . to receive ( :log ) . and_return ( log_double )
95- expect ( log_double ) . to receive ( :info ) . with ( "🔔 Default handler invoked for webhook 🔔" )
96- expect ( log_double ) . to receive ( :debug ) . with ( "received payload: #{ payload . inspect } " )
97-
98- fresh_handler . call ( payload : payload , headers : headers , config : config )
99- end
100-
101- it "does not log debug for nil payload" do
102- fresh_handler = described_class . new
103- log_double = instance_double ( Logger )
104- allow ( fresh_handler ) . to receive ( :log ) . and_return ( log_double )
105- expect ( log_double ) . to receive ( :info ) . with ( "🔔 Default handler invoked for webhook 🔔" )
106- expect ( log_double ) . not_to receive ( :debug )
107-
108- fresh_handler . call ( payload : nil , headers : headers , config : config )
109- end
110- end
11189 end
11290
11391 describe "inheritance" do
You can’t perform that action at this time.
0 commit comments