Sha256: d0734408942948ec2b4cc20455f02a75bcc301d4bb19e91472d6afeee651b75c

Contents?: true

Size: 842 Bytes

Versions: 9

Compression:

Stored size: 842 Bytes

Contents

require 'rspec'
require 'rspec/openapi/default_schema'
require 'rspec/openapi/record_builder'
require 'rspec/openapi/schema_builder'
require 'rspec/openapi/schema_file'
require 'rspec/openapi/schema_merger'

records = []

RSpec.configuration.after(:each) do |example|
  if example.metadata[:type] == :request && example.metadata[:openapi] != false && request && response
    records << RSpec::OpenAPI::RecordBuilder.build(self, example: example)
  end
end

RSpec.configuration.after(:suite) do
  title = File.basename(Dir.pwd)
  RSpec::OpenAPI::SchemaFile.new(RSpec::OpenAPI.path).edit do |spec|
    RSpec::OpenAPI::SchemaMerger.reverse_merge!(spec, RSpec::OpenAPI::DefaultSchema.build(title))
    records.each do |record|
      RSpec::OpenAPI::SchemaMerger.reverse_merge!(spec, RSpec::OpenAPI::SchemaBuilder.build(record))
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rspec-openapi-0.2.2 lib/rspec/openapi/hooks.rb
rspec-openapi-0.2.1 lib/rspec/openapi/hooks.rb
rspec-openapi-0.2.0 lib/rspec/openapi/hooks.rb
rspec-openapi-0.1.5 lib/rspec/openapi/hooks.rb
rspec-openapi-0.1.4 lib/rspec/openapi/hooks.rb
rspec-openapi-0.1.3 lib/rspec/openapi/hooks.rb
rspec-openapi-0.1.2 lib/rspec/openapi/hooks.rb
rspec-openapi-0.1.1 lib/rspec/openapi/hooks.rb
rspec-openapi-0.1.0 lib/rspec/openapi/hooks.rb