Sha256: b32d4e2d2b3751fc739414d6fde9941c3e5b20d86e0806a678b8cbfbe2b04fd7

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

require 'pact_broker/versions/service'

module PactBroker

  module Versions
    describe Service do

      describe ".find_versions_by_selector" do

        context "without a version selector" do
          let(:selector) { "Foo" }
        end

        context "with a version selector" do
          before do
            TestDataBuilder.new
              .create_pacticipant("Foo")
              .create_version("1.2.3")
              .create_version("4.5.6")
              .create_pacticipant("Bar")
              .create_version("1.2.3")
          end

          let(:selector) { "Foo/version/1.2.3" }

          subject { Service.find_versions_by_selector [selector] }

          context "when the version exists" do
            it "returns the specfied version" do
              expect(subject.first.number).to eq "1.2.3"
              expect(subject.first.pacticipant.name).to eq "Foo"
            end
          end

          context "when the version does not exist" do
            let(:selector) { "Wiffle/version/0.0.0" }

            it "returns nil" do
              expect(subject.first).to eq nil
            end
          end
        end
      end

      describe ".delete" do
        let!(:version) do
          TestDataBuilder.new
            .create_consumer
            .create_provider
            .create_consumer_version("1.2.3")
            .create_consumer_version_tag("prod")
            .create_pact
            .and_return(:consumer_version)
        end

        subject { Service.delete(version) }

        it "deletes the pact publication" do
          expect{ subject }.to change { PactBroker::Pacts::PactPublication.count }.by(-1)
        end

        it "deletes the tags" do
          expect{ subject }.to change { PactBroker::Domain::Tag.count }.by(-1)
        end

        it "deletes the version" do
          expect{ subject }.to change { PactBroker::Domain::Version.count }.by(-1)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.7.0.beta.2 spec/lib/pact_broker/versions/service_spec.rb
pact_broker-2.7.0.beta.1 spec/lib/pact_broker/versions/service_spec.rb