Sha256: 034e6b1818786a1042f1c4bcc911e66473a459eda45d7ee9e64eaa9589065693

Contents?: true

Size: 989 Bytes

Versions: 18

Compression:

Stored size: 989 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

18 entries across 18 versions & 1 rubygems

Version Path
pact_broker-2.112.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.111.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.109.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.109.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.108.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.107.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.107.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.106.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.105.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.104.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.103.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.102.2 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.102.1 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.102.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.101.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.100.0 lib/pact_broker/pacts/create_formatted_diff.rb
pact_broker-2.99.0 lib/pact_broker/pacts/create_formatted_diff.rb