From defdac3e38a4a69d989ef2467f43b8899a84adad Mon Sep 17 00:00:00 2001 From: Aleksei <9ceb2990-3744-4629-82f3-19bc5c80b3a2@mackevich.addymail.com> Date: Wed, 10 Apr 2024 19:40:17 +0500 Subject: [PATCH] Don't use monkey patching --- lib/rspec/openapi/extractors/hanami.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/rspec/openapi/extractors/hanami.rb b/lib/rspec/openapi/extractors/hanami.rb index d45238c..3db8921 100644 --- a/lib/rspec/openapi/extractors/hanami.rb +++ b/lib/rspec/openapi/extractors/hanami.rb @@ -37,17 +37,14 @@ def call(verb, path) InspectorAnalyzer = Inspector.new -# Monkey-patch hanami-router -module Hanami::Slice::ClassMethods +module InspectorAnalyzerPrepender def router(inspector: InspectorAnalyzer) - raise SliceLoadError, "#{self} must be prepared before loading the router" unless prepared? - - @_mutex.synchronize do - @_router ||= load_router(inspector: inspector) - end + super end end +Hanami::Slice::ClassMethods.prepend(InspectorAnalyzerPrepender) + # Extractor for hanami class << RSpec::OpenAPI::Extractors::Hanami = Object.new # @param [RSpec::ExampleGroups::*] context