Sha256: 3afcf35e3f72b0d7bebc0901a0aa33c25423bbff141b13fc3d6500dc53c72aab

Contents?: true

Size: 988 Bytes

Versions: 16

Compression:

Stored size: 988 Bytes

Contents

require "pact/matchers"
require "pact_broker/json"
require "pact/matchers/unix_diff_formatter"
require "pact_broker/pacts/sort_content"
require "pact_broker/pacts/content"

module PactBroker
  module Pacts
    class CreateFormattedDiff
      extend Pact::Matchers

      def self.call pact_json_content, previous_pact_json_content, raw: false
        pact_hash = JSON.load(pact_json_content, nil, PactBroker::PACT_PARSING_OPTIONS)
        previous_pact_hash = JSON.load(previous_pact_json_content, nil, PactBroker::PACT_PARSING_OPTIONS)

        if !raw
          pact_hash = SortContent.call(PactBroker::Pacts::Content.from_hash(pact_hash).without_ids.to_hash)
          previous_pact_hash = SortContent.call(PactBroker::Pacts::Content.from_hash(previous_pact_hash).without_ids.to_hash)
        end

        difference = diff(previous_pact_hash, pact_hash)
        Pact::Matchers::UnixDiffFormatter.call(difference, colour: false, include_explanation: false)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pact_broker-2.98.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.97.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.96.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.95.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.95.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.94.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.93.4 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.93.3 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.93.2 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.93.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.93.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.92.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.91.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.90.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.89.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.89.0 lib/pact_broker/pacts/create_formatted_diff.rb