Sha256: 4190254aad667847980c74ca9f3baeb9157386b5a51f3affd2a9d23d9b207ed3

Contents?: true

Size: 1.17 KB

Versions: 12

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

12 entries across 12 versions & 1 rubygems

Version Path
pact_broker-2.89.1 spec/features/update_environment_spec.rb
pact_broker-2.89.0 spec/features/update_environment_spec.rb
pact_broker-2.88.0 spec/features/update_environment_spec.rb
pact_broker-2.87.0 spec/features/update_environment_spec.rb
pact_broker-2.86.0 spec/features/update_environment_spec.rb
pact_broker-2.85.1 spec/features/update_environment_spec.rb
pact_broker-2.85.0 spec/features/update_environment_spec.rb
pact_broker-2.84.0 spec/features/update_environment_spec.rb
pact_broker-2.83.0 spec/features/update_environment_spec.rb
pact_broker-2.82.0 spec/features/update_environment_spec.rb
pact_broker-2.81.0 spec/features/update_environment_spec.rb
pact_broker-2.80.0 spec/features/update_environment_spec.rb