BigW Consortium Gitlab

success_warning_spec.rb 1.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
require 'spec_helper'

describe Gitlab::Ci::Status::SuccessWarning do
  subject do
    described_class.new(double('status'))
  end

  describe '#test' do
    it { expect(subject.text).to eq 'passed' }
  end

  describe '#label' do
    it { expect(subject.label).to eq 'passed with warnings' }
  end

  describe '#icon' do
    it { expect(subject.icon).to eq 'icon_status_warning' }
  end

  describe '#group' do
    it { expect(subject.group).to eq 'success_with_warnings' }
  end

  describe '.matches?' do
    let(:matchable) { double('matchable') }

    context 'when matchable subject is successful' do
      before do
        allow(matchable).to receive(:success?).and_return(true)
      end

      context 'when matchable subject has warnings' do
        before do
          allow(matchable).to receive(:has_warnings?).and_return(true)
        end

        it 'is a correct match' do
          expect(described_class.matches?(matchable, double)).to eq true
        end
      end

      context 'when matchable subject does not have warnings' do
        before do
          allow(matchable).to receive(:has_warnings?).and_return(false)
        end

        it 'does not match' do
          expect(described_class.matches?(matchable, double)).to eq false
        end
      end
    end

    context 'when matchable subject is not successful' do
      before do
        allow(matchable).to receive(:success?).and_return(false)
      end

      context 'when matchable subject has warnings' do
        before do
          allow(matchable).to receive(:has_warnings?).and_return(true)
        end

        it 'does not match' do
          expect(described_class.matches?(matchable, double)).to eq false
        end
      end

      context 'when matchable subject does not have warnings' do
        it 'does not match' do
          expect(described_class.matches?(matchable, double)).to eq false
        end
      end
    end
  end
end