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

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

Instance Method Summary collapse

Instance Method Details

#run(*args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rspec/openapi/minitest_hooks.rb', line 13

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)
    if record
      RECORD_MUTEX.synchronize do
        RSpec::OpenAPI::ParallelRecords.schedule_dump!
        RSpec::OpenAPI.path_records[path] << record
      end
    end
  end
  result
end