Sha256: 964ad0d2d8ac14fb0ced874b8d5e3b62bbf15ceb7273a765b5e440520cbdf55b

Contents?: true

Size: 1.57 KB

Versions: 37

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'
require 'pact_broker/groups/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::Relationship.new(consumer_a, provider_x) }
        let(:relationship_2) { Domain::Relationship.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(Pacticipants::Service).to receive(:find_relationships).and_return(relationship_list)
          allow(Relationships::Groupify).to receive(:call).and_return(groups)
        end

        it "retrieves a list of the relationships" do
          allow(Pacticipants::Service).to receive(:find_relationships)
          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

37 entries across 37 versions & 1 rubygems

Version Path
pact_broker-2.0.2 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.8 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.7 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.6 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-1.18.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.5 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-1.18.0.beta.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-1.17.2 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-1.17.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.4 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.3 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.2 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-2.0.0.beta.1 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-1.17.0 spec/lib/pact_broker/groups/service_spec.rb
pact_broker-1.16.0 spec/lib/pact_broker/groups/service_spec.rb