Sha256: 33fb16c5e6ee15c7a99829ab8e705a9d182bf79dc60f227ee922de1f2eda21d4

Contents?: true

Size: 1.17 KB

Versions: 12

Compression:

Stored size: 1.17 KB

Contents

require "pact_broker/pacts/generate_interaction_sha"

module PactBroker
  module Pacts
    describe GenerateInteractionSha do
      describe ".call" do
        let(:interaction_hash) do
          {
            "description" => "foo",
            "providerStates" => [
              "name" => "bar",
              "params" => {
                "wiffle" => "bar",
                "meep" => "eek"
              }
            ]
          }
        end

        let(:interaction_hash_with_different_key_order) do
          {
            "providerStates" => [
              "name" => "bar",
              "params" => {
                "meep" => "eek",
                "wiffle" => "bar"
              }
            ],
            "description" => "foo"
          }
        end

        subject { GenerateInteractionSha.call(interaction_hash) }

        it "generates a SHA based on the sorted keys" do
          expect(subject).to eq "57d06e151eca35083e4d6b585b4d4fab2e2ed6b7"
        end

        it "generates the same SHA if the keys are ordered differently" do
          expect(subject).to eq GenerateInteractionSha.call(interaction_hash_with_different_key_order)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pact_broker-2.89.1 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.89.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.88.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.87.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.86.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.85.1 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.85.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.84.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.83.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.82.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.81.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb
pact_broker-2.80.0 spec/lib/pact_broker/pacts/generate_interaction_sha_spec.rb