lib/rspec/openapi/minitest_hooks.rb in rspec-openapi-0.8.1 vs lib/rspec/openapi/minitest_hooks.rb in rspec-openapi-0.9.0

- old
+ new

@@ -3,15 +3,11 @@ require 'minitest' module RSpec::OpenAPI::Minitest Example = Struct.new(:context, :description, :metadata, :file_path) - module TestPatch - def self.prepended(base) - base.extend(ClassMethods) - end - + module RunPatch def run(*args) result = super if ENV['OPENAPI'] && self.class.openapi? file_path = method(name).source_location.first human_name = name.sub(/^test_/, '').gsub(/_/, ' ') @@ -20,11 +16,17 @@ record = RSpec::OpenAPI::RecordBuilder.build(self, example: example) RSpec::OpenAPI.path_records[path] << record if record end result end + end + module ActivateOpenApiClassMethods + def self.prepended(base) + base.extend(ClassMethods) + end + module ClassMethods def openapi? @openapi end @@ -33,13 +35,15 @@ end end end end -Minitest::Test.prepend RSpec::OpenAPI::Minitest::TestPatch +Minitest::Test.prepend RSpec::OpenAPI::Minitest::ActivateOpenApiClassMethods -Minitest.after_run do - if ENV['OPENAPI'] +if ENV['OPENAPI'] + Minitest::Test.prepend RSpec::OpenAPI::Minitest::RunPatch + + Minitest.after_run do result_recorder = RSpec::OpenAPI::ResultRecorder.new(RSpec::OpenAPI.path_records) result_recorder.record_results! puts result_record.error_message if result_recorder.errors? end end