Module: OpenapiRuby::Adapters::RSpec

Defined in:
lib/openapi_ruby/adapters/rspec.rb

Defined Under Namespace

Modules: ExampleGroupHelpers, ExampleHelpers

Class Method Summary collapse

Class Method Details

.install!Object



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/openapi_ruby/adapters/rspec.rb', line 270

def self.install!
  ::RSpec.configure do |config|
    config.extend ExampleGroupHelpers, type: :openapi
    config.include ExampleHelpers, type: :openapi

    if defined?(::RSpec::Rails)
      config.include ::RSpec::Rails::RequestExampleGroup, type: :openapi
    end

    config.after(:suite) do
      OpenapiRuby::Generator::SchemaWriter.generate_all!
    rescue => e
      warn "[openapi_ruby] Schema generation failed: #{e.message}"
    end
  end
end