class Pact::Provider::PactSpecRunner
def configure_rspec
def configure_rspec config = ::RSpec.configuration config.color = true unless options[:silent] config.error_stream = $stderr config.output_stream = $stdout end formatter = ::RSpec::Core::Formatters::DocumentationFormatter.new(config.output) @json_formatter = ::RSpec::Core::Formatters::JsonFormatter.new(StringIO.new) reporter = ::RSpec::Core::Reporter.new(formatter, @json_formatter) config.instance_variable_set(:@reporter, reporter) end
def initialize spec_definitions, options = {}
def initialize spec_definitions, options = {} @spec_definitions = spec_definitions @options = options @results = nil end
def initialize_specs
def initialize_specs spec_definitions.each do | spec_definition | require_pact_helper spec_definition options = {consumer: spec_definition[:consumer], save_pactfile_to_tmp: true} honour_pactfile spec_definition[:uri], options end end
def require_pact_helper spec_definition
def require_pact_helper spec_definition if spec_definition[:support_file] $stderr.puts "Specifying a support_file is deprecated. Please create a pact_helper.rb instead." require spec_definition[:support_file] else require 'pact/provider/client_project_pact_helper' end end
def run
def run initialize_specs configure_rspec run_specs end
def run_specs
def run_specs config = ::RSpec.configuration world = ::RSpec::world exit_code = config.reporter.report(world.example_count, nil) do |reporter| begin config.run_hook(:before, :suite) world.example_groups.ordered.map {|g| g.run(reporter)}.all? ? 0 : config.failure_exit_code ensure config.run_hook(:after, :suite) end end @output = @json_formatter.output_hash exit_code end