Sha256: d252def23f2e6185659230a0b7e3a0b1e50431c0a2aca2e6a7b1dc0be359b2b9

Contents?: true

Size: 1.59 KB

Versions: 63

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'
require 'pact_broker/groups/service'
require 'pact_broker/index/service'

module PactBroker

  module Groups
    describe Service do

      describe "#find_group_containing" do

        let(:consumer_a) { double('consumer a', name: 'consumer a', id: 1)}
        let(:consumer_b) { double('consumer b', name: 'consumer b', id: 2)}

        let(:provider_x) { double('provider x', name: 'provider x', id: 3)}
        let(:provider_y) { double('provider y', name: 'provider y', id: 4)}

        let(:relationship_1) { Domain::IndexItem.new(consumer_a, provider_x) }
        let(:relationship_2) { Domain::IndexItem.new(consumer_b, provider_y) }

        let(:group_1) { Domain::Group.new(relationship_1) }
        let(:group_2) { Domain::Group.new(relationship_2) }

        let(:relationship_list) { double('relationship list') }
        let(:groups) { [group_1, group_2]}

        subject  { Service.find_group_containing(consumer_b) }

        before do
          allow(PactBroker::Index::Service).to receive(:find_index_items).and_return(relationship_list)
          allow(Relationships::Groupify).to receive(:call).and_return(groups)
        end

        it "retrieves a list of the relationships" do
          allow(Index::Service).to receive(:find_index_items)
          subject
        end

        it "turns the relationships into groups" do
          expect(Relationships::Groupify).to receive(:call).with(relationship_list)
          subject
        end

        it "returns the Group containing the given pacticipant" do
          expect(subject).to be group_2
        end

      end

    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
pact_broker-2.79.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.79.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.78.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.78.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.77.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.76.2 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.76.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.76.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.75.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.74.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.74.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.73.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.72.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.71.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.70.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.69.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.68.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.68.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.67.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.66.0 spec/lib/pact_broker/groups/service_spec.rb