Sha256: 9877e71c1872e19cf653108da810b3707e731a95808be6a8c7509f222d623df0

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

require 'pact/provider/verification_results/verification_result'
module Pact
  module Provider
    module VerificationResults
      class Create

        def self.call pact_json, suite_context
          new(pact_json, suite_context).call
        end

        def initialize pact_json, suite_context
          @pact_json = pact_json
          @suite_context = suite_context
        end

        def call
          VerificationResult.new(!any_failures?, Pact.configuration.provider.application_version)
        end

        private

        def pact_hash
          @pact_hash ||= json_load(pact_json)
        end

        def json_load json
          JSON.load(json, nil, { max_nesting: 50 })
        end

        def count_failures_for_pact_json
          suite_context.reporter.failed_examples.collect{ |e| e.metadata[:pact_json] == pact_json }.uniq.size
        end

        def any_failures?
          count_failures_for_pact_json > 0
        end

        attr_reader :pact_json, :suite_context
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact-1.12.0 lib/pact/provider/verification_results/create.rb
pact-1.11.1 lib/pact/provider/verification_results/create.rb
pact-1.11.0 lib/pact/provider/verification_results/create.rb