Module: OpenapiRuby::Adapters::RSpec

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

Defined Under Namespace

Modules: ExampleGroupHelpers, ExampleHelpers Classes: OperationProxy, PathProxy, ResponseProxy

Class Method Summary collapse

Class Method Details

.install!Object



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/openapi_ruby/adapters/rspec.rb', line 281

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

    # Make type: :openapi behave like request specs (includes integration test methods)
    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