Skip to content

Commit

Permalink
Don't use monkey patching
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei committed Apr 10, 2024
1 parent 25fa2ff commit defdac3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/rspec/openapi/extractors/hanami.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ def call(verb, path)

InspectorAnalyzer = Inspector.new

# Monkey-patch hanami-router
module Hanami::Slice::ClassMethods
module InspectorAnalyzerPrepender

Check notice

Code scanning / Rubocop

Document classes and non-namespace modules. Note

Style/Documentation: Missing top-level documentation comment for 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
Expand Down

0 comments on commit defdac3

Please sign in to comment.