Skip to content

Commit

Permalink
Dont' log missing Rails/Hanami unless DEBUG (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Apr 17, 2024
1 parent 3394219 commit dc14c65
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions lib/rspec/openapi.rb
Expand Up @@ -15,20 +15,24 @@
require 'rspec/openapi/extractors'
require 'rspec/openapi/extractors/rack'

begin
require 'hanami'
rescue LoadError
puts 'Hanami not detected'
else
require 'rspec/openapi/extractors/hanami'
end
if ENV['OPENAPI']
DEBUG_ENABLED = ['', '1', 'true'].include?(ENV['DEBUG']&.downcase)

begin
require 'hanami'
rescue LoadError
warn 'Hanami not detected' if DEBUG_ENABLED
else
require 'rspec/openapi/extractors/hanami'
end

begin
require 'rails'
rescue LoadError
puts 'Rails not detected'
else
require 'rspec/openapi/extractors/rails'
begin
require 'rails'
rescue LoadError
warn 'Rails not detected' if DEBUG_ENABLED
else
require 'rspec/openapi/extractors/rails'
end
end

require 'rspec/openapi/minitest_hooks' if Object.const_defined?('Minitest')
Expand Down

0 comments on commit dc14c65

Please sign in to comment.