Sha256: a979805b87f34fb0a9559e27391b5f365d20685f3d2a12ac792f631da31b8e71

Contents?: true

Size: 1.9 KB

Versions: 47

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'
require 'pact_broker/ui/view_models/index_items'

module PactBroker
  module UI
    module ViewDomain
      describe IndexItems do

        let(:relationship_model_4) { double("PactBroker::Domain::IndexItem", consumer_name: "A", provider_name: "X") }
        let(:relationship_model_2) { double("PactBroker::Domain::IndexItem", consumer_name: "a", provider_name: "y") }
        let(:relationship_model_3) { double("PactBroker::Domain::IndexItem", consumer_name: "A", provider_name: "Z") }
        let(:relationship_model_1) { double("PactBroker::Domain::IndexItem", consumer_name: "C", provider_name: "A") }

        subject { IndexItems.new([relationship_model_1, relationship_model_3, relationship_model_4, relationship_model_2]) }

        describe "#each" do

          it "yields the relationships in order" do
            list = []

            subject.each do | relationship_view_model |
              list << [relationship_view_model.consumer_name, relationship_view_model.provider_name]
            end

            expect(list).to eq([["A", "X"],["a","y"],["A","Z"],["C", "A"]])

          end
        end

        describe "size_label" do
          context "when there is 1 relationship" do
            subject { IndexItems.new([relationship_model_1]) }

            it "returns '1 pact'" do
              expect(subject.size_label).to eq "1 pact"
            end
          end
          context "when there are 0 relationships" do
            subject { IndexItems.new([]) }

            it "returns '0 pacts'" do
              expect(subject.size_label).to eq "0 pacts"
            end
          end
          context "when there is more than 1 relationship" do
            subject { IndexItems.new([relationship_model_1, relationship_model_1]) }

            it "returns 'x pacts'" do
              expect(subject.size_label).to eq "2 pacts"
            end
          end
        end
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
pact_broker-2.40.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.39.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.38.1 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.38.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.37.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.36.1 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.36.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.35.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.34.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.33.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.32.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.31.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.30.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.29.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.27.6 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.27.5 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.27.4 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.27.3 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.27.2 spec/lib/pact_broker/ui/view_models/index_items_spec.rb
pact_broker-2.27.0 spec/lib/pact_broker/ui/view_models/index_items_spec.rb