Sha256: dbec8065e1599c3a99678140f82ee505b3f9b8e1401ac40420731289f609567b

Contents?: true

Size: 1.77 KB

Versions: 3

Compression:

Stored size: 1.77 KB

Contents

require 'pact_broker/webhooks/status'

module PactBroker
  module Webhooks
    describe Status do
      let(:webhooks) { [double('webhook')]}
      let(:latest_triggered_webhooks) { [ triggered_webhook_1, triggered_webhook_2] }
      let(:pact) { double('pact') }
      let(:triggered_webhook_1) { double('triggered_webhook', status: status_1) }
      let(:triggered_webhook_2) { double('triggered_webhook', status: status_2) }
      let(:status_1) { TriggeredWebhook::STATUS_SUCCESS }
      let(:status_2) { TriggeredWebhook::STATUS_SUCCESS }

      subject { Status.new(pact, webhooks, latest_triggered_webhooks) }

      context "when there are no webhooks configured" do
        let(:webhooks) { [] }
        its(:to_sym) { is_expected.to eq :none }
      end

      context "when there are webhooks, but no triggered webhooks" do
        let(:latest_triggered_webhooks) { [] }
        its(:to_sym) { is_expected.to eq :not_run }
      end

      context "when the most recent triggered webhooks are successful" do
        its(:to_sym) { is_expected.to eq :success }
      end

      context "when one of the most recent executions is a failure" do
        let(:status_1) { TriggeredWebhook::STATUS_FAILURE }
        its(:to_sym) { is_expected.to eq :failure }
      end

      context "when one of the most recent executions is a failure and one is retrying" do
        let(:status_1) { TriggeredWebhook::STATUS_FAILURE }
        let(:status_2) { TriggeredWebhook::STATUS_RETRYING }
        its(:to_sym) { is_expected.to eq :retrying }
      end

      context "when the most recent executions are failures" do
        let(:status_1) { TriggeredWebhook::STATUS_FAILURE }
        let(:status_2) { TriggeredWebhook::STATUS_FAILURE }
        its(:to_sym) { is_expected.to eq :failure }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-2.6.0 spec/lib/pact_broker/webhooks/status_spec.rb
pact_broker-2.5.1 spec/lib/pact_broker/webhooks/status_spec.rb
pact_broker-2.5.0 spec/lib/pact_broker/webhooks/status_spec.rb