debian-mirror-gitlab/spec/lib/gitlab/ci/status/success_warning_spec.rb

80 lines
1.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe Gitlab::Ci::Status::SuccessWarning do
2018-05-09 12:01:36 +05:30
let(:status) { double('status') }
2017-08-17 22:00:37 +05:30
subject do
2018-05-09 12:01:36 +05:30
described_class.new(status)
2017-08-17 22:00:37 +05:30
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
2018-03-17 18:26:18 +05:30
it { expect(subject.icon).to eq 'status_warning' }
2017-08-17 22:00:37 +05:30
end
describe '#group' do
2019-07-31 22:56:46 +05:30
it { expect(subject.group).to eq 'success-with-warnings' }
2017-08-17 22:00:37 +05:30
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