@@ -240,6 +240,28 @@ def self.valid?(payload:, headers:, config:)
240
240
end
241
241
end
242
242
243
+ it "raises error when auth plugin class is not found after loading" do
244
+ temp_auth_dir = File . join ( temp_dir , "auth_missing_class" )
245
+ FileUtils . mkdir_p ( temp_auth_dir )
246
+
247
+ # Create plugin file that doesn't define the expected class
248
+ missing_file = File . join ( temp_auth_dir , "missing_auth.rb" )
249
+ File . write ( missing_file , <<~RUBY )
250
+ # This file doesn't define MissingAuth class
251
+ module Hooks
252
+ module Plugins
253
+ module Auth
254
+ # Nothing here
255
+ end
256
+ end
257
+ end
258
+ RUBY
259
+
260
+ expect {
261
+ described_class . send ( :load_custom_auth_plugin , missing_file , temp_auth_dir )
262
+ } . to raise_error ( StandardError , /Auth plugin class not found in Hooks::Plugins::Auth namespace: MissingAuth/ )
263
+ end
264
+
243
265
describe "handler plugin loading failures" do
244
266
it "raises error when handler plugin file fails to load" do
245
267
temp_handler_dir = File . join ( temp_dir , "handler_failures" )
@@ -298,6 +320,23 @@ def call(payload:, headers:, env:, config:)
298
320
described_class . send ( :load_custom_handler_plugin , wrong_file , temp_handler_dir )
299
321
} . to raise_error ( StandardError , /Handler class must inherit from Hooks::Plugins::Handlers::Base/ )
300
322
end
323
+
324
+ it "raises error when handler plugin class is not found after loading" do
325
+ temp_handler_dir = File . join ( temp_dir , "handler_missing_class" )
326
+ FileUtils . mkdir_p ( temp_handler_dir )
327
+
328
+ # Create plugin file that doesn't define the expected class
329
+ missing_file = File . join ( temp_handler_dir , "missing_handler.rb" )
330
+ File . write ( missing_file , <<~RUBY )
331
+ # This file doesn't define MissingHandler class
332
+ class SomeOtherClass
333
+ end
334
+ RUBY
335
+
336
+ expect {
337
+ described_class . send ( :load_custom_handler_plugin , missing_file , temp_handler_dir )
338
+ } . to raise_error ( StandardError , /Handler class not found: MissingHandler/ )
339
+ end
301
340
end
302
341
303
342
describe "lifecycle plugin loading failures" do
@@ -358,6 +397,23 @@ def on_request(env)
358
397
described_class . send ( :load_custom_lifecycle_plugin , wrong_file , temp_lifecycle_dir )
359
398
} . to raise_error ( StandardError , /Lifecycle plugin class must inherit from Hooks::Plugins::Lifecycle/ )
360
399
end
400
+
401
+ it "raises error when lifecycle plugin class is not found after loading" do
402
+ temp_lifecycle_dir = File . join ( temp_dir , "lifecycle_missing_class" )
403
+ FileUtils . mkdir_p ( temp_lifecycle_dir )
404
+
405
+ # Create plugin file that doesn't define the expected class
406
+ missing_file = File . join ( temp_lifecycle_dir , "missing_lifecycle.rb" )
407
+ File . write ( missing_file , <<~RUBY )
408
+ # This file doesn't define MissingLifecycle class
409
+ class SomeOtherClass
410
+ end
411
+ RUBY
412
+
413
+ expect {
414
+ described_class . send ( :load_custom_lifecycle_plugin , missing_file , temp_lifecycle_dir )
415
+ } . to raise_error ( StandardError , /Lifecycle plugin class not found: MissingLifecycle/ )
416
+ end
361
417
end
362
418
363
419
describe "instrument plugin loading failures" do
@@ -418,6 +474,23 @@ def record(metric_name, value, tags = {})
418
474
described_class . send ( :load_custom_instrument_plugin , wrong_file , temp_instrument_dir )
419
475
} . to raise_error ( StandardError , /Instrument plugin class must inherit from StatsBase or FailbotBase/ )
420
476
end
477
+
478
+ it "raises error when instrument plugin class is not found after loading" do
479
+ temp_instrument_dir = File . join ( temp_dir , "instrument_missing_class" )
480
+ FileUtils . mkdir_p ( temp_instrument_dir )
481
+
482
+ # Create plugin file that doesn't define the expected class
483
+ missing_file = File . join ( temp_instrument_dir , "missing_instrument.rb" )
484
+ File . write ( missing_file , <<~RUBY )
485
+ # This file doesn't define MissingInstrument class
486
+ class SomeOtherClass
487
+ end
488
+ RUBY
489
+
490
+ expect {
491
+ described_class . send ( :load_custom_instrument_plugin , missing_file , temp_instrument_dir )
492
+ } . to raise_error ( StandardError , /Instrument plugin class not found: MissingInstrument/ )
493
+ end
421
494
end
422
495
end
423
496
end
0 commit comments