Sha256: a39c8b6eaaae3edd31f4d23ef85115b044f1c40870eed2c8ea297ee3eed36c91

Contents?: true

Size: 1.68 KB

Versions: 19

Compression:

Stored size: 1.68 KB

Contents

require 'pact_broker/api/resources/can_i_deploy'

module PactBroker
  module Api
    module Resources
      describe CanIDeploy do
        include_context "stubbed services"

        before do
          allow(pacticipant_service).to receive(:find_pacticipant_by_name).and_return(pacticipant)
          allow(matrix_service).to receive(:find).and_return(results)
          allow_any_instance_of(described_class).to receive(:matrix_service).and_return(matrix_service)
          allow(PactBroker::Api::Decorators::MatrixDecorator).to receive(:new).and_return(decorator)
        end

        let(:results) { double('results') }
        let(:pacticipant) { double('pacticipant') }
        let(:decorator) { instance_double('PactBroker::Api::Decorators::MatrixDecorator', to_json: 'response_body') }
        let(:matrix_service) { class_double("PactBroker::Matrix::Service").as_stubbed_const }

        let(:query) do
          {
            pacticipant: "Foo",
            version: "1.2.3",
            to: "prod"
          }
        end

        subject { get("/can-i-deploy", query, { 'HTTP_ACCEPT' => 'application/hal+json'}) }

        context "with the wrong query" do
          let(:query) { {} }

          it "returns a 400" do
            expect(subject.status).to eq 400
            expect(JSON.parse(subject.body)["errors"]["pacticipant"].first).to_not be_empty
          end
        end

        context "when the pacticipant does not exist" do
          let(:pacticipant) { nil }

          it "returns a 400" do
            expect(subject.status).to eq 400
            expect(JSON.parse(subject.body)["errors"]["pacticipant"].first).to match /Foo.*found/
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pact_broker-2.79.1 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.79.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.78.1 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.78.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.77.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.76.2 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.76.1 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.76.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.75.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.74.1 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.74.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.73.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.72.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.71.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.70.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.69.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.68.1 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.68.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb
pact_broker-2.67.0 spec/lib/pact_broker/api/resources/can_i_deploy_spec.rb