Sha256: a30ab69f47c4f191de24a3033296cf52301ba9c000763b4e2c9e377a3b48dda3

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

module PactBroker
  module Webhooks
    describe WebhookExecutionResult do
      subject { WebhookExecutionResult::new(request, response, nil) }
      let(:request) do
        Net::HTTP::Get.new("http://example.org?foo=bar")
      end

      context "When 'webhook_http_code_success' has [200, 201]" do
        before do
          allow(PactBroker.configuration).to receive(:webhook_http_code_success).and_return([200, 201])
        end

        context "and response is '200'" do
          let(:response) { double(code: "200") }

          it "then it should be success" do
            expect(subject.success?).to be_truthy
          end
        end

        context "and response is '400'" do
          let(:response) { double(code: "400") }

          it "then it should fail" do
            expect(subject.success?).to be_falsey
          end
        end
      end


      context "When 'webhook_http_code_success' has [400, 401]" do
        before do
          allow(PactBroker.configuration).to receive(:webhook_http_code_success).and_return([400, 401])
        end

        context "and response is '200'" do
          let(:response) { double(code: "200") }

          it "then it should fail" do
            expect(subject.success?).to be_falsey
          end
        end

        context "and response is '400'" do
          let(:response) { double(code: "400") }

          it "then it should be success" do
            expect(subject.success?).to be_truthy
          end
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pact_broker-2.84.0 spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
pact_broker-2.83.0 spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
pact_broker-2.82.0 spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
pact_broker-2.81.0 spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb
pact_broker-2.80.0 spec/lib/pact_broker/api/resources/webhook_execution_result_spec.rb