Sha256: 76b2f59e65b9e0794d859ccab40278946e9a94170488f36792d5e136e48115c4

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

require 'pact_broker/api/pact_broker_urls'

describe "Updating an environment" do
  before do
    td.create_environment("test", uuid: "1234", contacts: [ { name: "Foo" } ] )
  end
  let(:path) { PactBroker::Api::PactBrokerUrls.environment_url(td.and_return(:environment)) }
  let(:headers) { {'CONTENT_TYPE' => 'application/json'} }
  let(:response_body) { JSON.parse(last_response.body, symbolize_names: true)}
  let(:environment_hash) do
    {
      name: "test",
      production: false,
      displayName: "Testing"
    }
  end

  subject { put(path, environment_hash.to_json, headers) }

  it { is_expected.to be_a_hal_json_success_response }

  it "returns the updated environment" do
    subject
    expect(response_body[:displayName]).to eq "Testing"
    expect(response_body[:contacts]).to be nil
  end

  context "when the environment doesn't exist" do
    let(:path) { "/environments/5678" }

    it "returns a 404" do
      expect(subject.status).to eq 404
    end
  end

  context "with invalid params" do
    let(:environment_hash) { {} }

    it "returns a 400 response" do
      expect(subject.status).to be 400
      expect(response_body[:errors]).to_not be nil
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pact_broker-2.79.1 spec/features/update_environment_spec.rb
pact_broker-2.79.0 spec/features/update_environment_spec.rb
pact_broker-2.78.1 spec/features/update_environment_spec.rb
pact_broker-2.78.0 spec/features/update_environment_spec.rb