Skip to content

Commit

Permalink
Refactor require system for extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei committed Apr 11, 2024
1 parent 1f8270b commit 3230778
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/rspec/openapi.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'rspec/openapi/version'
require 'rspec/openapi/components_updater'
require 'rspec/openapi/default_schema'
Expand All @@ -16,8 +15,19 @@
require 'rspec/openapi/extractors'
require 'rspec/openapi/extractors/rack'

require 'rspec/openapi/extractors/hanami' if Bundler.load.specs.map(&:name).include?('hanami')
require 'rspec/openapi/extractors/rails' if Bundler.load.specs.map(&:name).include?('rails')
begin
require 'hanami'
require 'rspec/openapi/extractors/hanami'
rescue LoadError
puts 'Hanami not detected'

Check warning on line 22 in lib/rspec/openapi.rb

View check run for this annotation

Codecov / codecov/patch

lib/rspec/openapi.rb#L22

Added line #L22 was not covered by tests
end

begin
require 'rails'
require 'rspec/openapi/extractors/rails'
rescue LoadError
puts 'Rails not detected'

Check warning on line 29 in lib/rspec/openapi.rb

View check run for this annotation

Codecov / codecov/patch

lib/rspec/openapi.rb#L29

Added line #L29 was not covered by tests
end

require 'rspec/openapi/minitest_hooks' if Object.const_defined?('Minitest')
require 'rspec/openapi/rspec_hooks' if ENV['OPENAPI'] && Object.const_defined?('RSpec')
Expand Down

0 comments on commit 3230778

Please sign in to comment.