Module: RSpec::OpenAPI::Minitest::RunPatch

Defined in:
lib/rspec/openapi/minitest_hooks.rb

Instance Method Summary collapse

Instance Method Details

#run(*args) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rspec/openapi/minitest_hooks.rb', line 9

def run(*args)
  result = super
  if ENV['OPENAPI'] && self.class.openapi?
    file_path = method(name).source_location.first
    human_name = name.sub(/^test_/, '').gsub('_', ' ')
    example = Example.new(self, human_name, {}, file_path)
    path = RSpec::OpenAPI.path.then { |p| p.is_a?(Proc) ? p.call(example) : p }
    record = RSpec::OpenAPI::RecordBuilder.build(self, example: example, extractor: SharedHooks.find_extractor)
    RSpec::OpenAPI.path_records[path] << record if record
  end
  result
end