Sha256: 89fc65baad757e3f84aa2bd6a481c6d4bf030d0e1a7e5e31e56c6ddf5f579027

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

RSpec.describe "publishing a pact using the all in one endpoint" do
  let(:request_body_hash) do
    {
      :pacticipantName => "Foo",
      :pacticipantVersionNumber => "1",
      :branch => "main",
      :tags => ["a", "b"],
      :buildUrl => "http://ci/builds/1234",
      :contracts => [
        {
          :consumerName => "Foo",
          :providerName => "Bar",
          :specification => "pact",
          :contentType => "application/json",
          :content => encoded_contract,
          :onConflict => "overwrite",
        }
      ]
    }
  end
  let(:rack_headers) { { "CONTENT_TYPE" => "application/json", "HTTP_ACCEPT" => "application/hal+json" } }
  let(:contract) { { consumer: { name: "Foo" }, provider: { name: "Bar" }, interactions: [] }.to_json }
  let(:encoded_contract) { Base64.strict_encode64(contract) }
  let(:path) { "/contracts/publish" }

  subject { post(path, request_body_hash.to_json, rack_headers) }

  it { is_expected.to be_a_hal_json_success_response }

  it "creates a pact" do
    expect { subject }.to change { PactBroker::Pacts::PactPublication.count }.by(1)
    expect(PactBroker::Pacts::PactVersion.last.content).to eq contract
  end

  context "with a validation error" do
    before do
      request_body_hash.delete(:pacticipantName)
    end

    it { is_expected.to be_a_json_error_response("missing") }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pact_broker-2.88.0 spec/features/publish_pact_all_in_one_spec.rb
pact_broker-2.87.0 spec/features/publish_pact_all_in_one_spec.rb
pact_broker-2.86.0 spec/features/publish_pact_all_in_one_spec.rb
pact_broker-2.85.1 spec/features/publish_pact_all_in_one_spec.rb
pact_broker-2.85.0 spec/features/publish_pact_all_in_one_spec.rb
pact_broker-2.84.0 spec/features/publish_pact_all_in_one_spec.rb