Sha256: 829633828b13ed0a45512e90869d13d26cdf2d5f42d7e26e25d5790705315804

Contents?: true

Size: 1.8 KB

Versions: 35

Compression:

Stored size: 1.8 KB

Contents

require 'spec/support/provider_state_builder'

describe "Get provider pacts" do

  let(:path) { "/pacts/provider/Provider/latest" }
  let(:last_response_body) { JSON.parse(subject.body, symbolize_names: true) }

  subject { get path; last_response }

  context "when the provider exists" do

    before do
      ProviderStateBuilder.new
        .create_provider("Provider")
        .create_consumer("Consumer")
        .create_consumer_version("1.0.0")
        .create_consumer_version_tag("prod")
        .create_pact
        .create_consumer_version("1.2.3")
        .create_pact
        .create_consumer("Consumer 2")
        .create_consumer_version("4.5.6")
        .create_pact
    end

    context "with no tag specified" do

      it "returns a 200 HAL JSON response" do
        expect(subject).to be_a_hal_json_success_response
      end

      it "returns a list of links to the pacts" do
        expect(last_response_body[:_links][:pacts].size).to eq 2
      end
    end

    context "with a tag specified" do

      let(:path) { "/pacts/provider/Provider/latest/prod" }

      it "returns a 200 HAL JSON response" do
        expect(subject).to be_a_hal_json_success_response
      end

      it "returns a list of links to the pacts" do
        expect(last_response_body[:_links][:pacts].size).to eq 1
      end
    end

    context "with a tag with no pacts" do

      let(:path) { "/pacts/provider/Provider/latest/foo" }

      it "returns a 200 HAL JSON response" do
        expect(subject).to be_a_hal_json_success_response
      end

      it "returns a list of links to the pacts" do
        expect(last_response_body[:_links][:pacts].size).to eq 0
      end
    end

  end

  context "when the provider does not exist" do

    it "returns a 404 response" do
      expect(subject).to be_a_404_response
    end

  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
pact_broker-2.0.5 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.4 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.3 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.2 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.1 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.8 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.7 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.6 spec/features/get_provider_pacts_spec.rb
pact_broker-1.18.0 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.5 spec/features/get_provider_pacts_spec.rb
pact_broker-1.18.0.beta.1 spec/features/get_provider_pacts_spec.rb
pact_broker-1.17.2 spec/features/get_provider_pacts_spec.rb
pact_broker-1.17.1 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.4 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.3 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.2 spec/features/get_provider_pacts_spec.rb
pact_broker-2.0.0.beta.1 spec/features/get_provider_pacts_spec.rb
pact_broker-1.17.0 spec/features/get_provider_pacts_spec.rb
pact_broker-1.16.0 spec/features/get_provider_pacts_spec.rb