Sha256: cc802a4356855ee0efbc30bd5bedb7bcc8fc8e90c70ed4b59ccbbf76db35fdd1

Contents?: true

Size: 1.78 KB

Versions: 19

Compression:

Stored size: 1.78 KB

Contents

require 'pact_broker/client/merge_pacts'

module PactBroker
  module Client
    describe MergePacts do
      describe ".call" do
        let(:pact_hash_1) do
          {
            other: 'info',
            interactions: [
              {providerState: 1, description: 1, foo: 'bar' }
            ]
          }
        end

        let(:pact_hash_2) do
          {
            interactions: [
              {providerState: 2, description: 2, foo: 'wiffle' }
            ]
          }
        end

        let(:pact_hash_3) do
          {
            interactions: [
              {providerState: 3, description: 3, foo: 'meep' },
              {providerState: 1, description: 1, foo: 'bar' }
            ]
          }
        end

        let(:pact_hashes) { [pact_hash_1, pact_hash_2, pact_hash_3] }

        let(:expected_merge) do
          {
            other: 'info',
            interactions: [
              {providerState: 1, description: 1, foo: 'bar' },
              {providerState: 2, description: 2, foo: 'wiffle' },
              {providerState: 3, description: 3, foo: 'meep' }
            ]
          }
        end

        subject { MergePacts.call(pact_hashes) }

        it "merges the interactions by consumer/provider" do
          expect(subject).to eq expected_merge
        end

        context "when an interaction is found with the same state and description but has a difference elsewhere" do
          let(:pact_hash_3) do
            {
              interactions: [
                {providerState: 3, description: 3, foo: 'meep' },
                {providerState: 1, description: 1, foo: 'different' }
              ]
            }
          end

          it "raises an error" do
            expect { subject }.to raise_error PactMergeError
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pact_broker-client-1.18.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.17.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.16.2 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.16.1 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.16.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.15.1 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.15.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.14.1 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.14.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.13.1 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.13.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.12.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.11.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.10.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.9.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.8.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.7.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.6.0 spec/lib/pact_broker/client/merge_pacts_spec.rb
pact_broker-client-1.5.0 spec/lib/pact_broker/client/merge_pacts_spec.rb