debian-mirror-gitlab/spec/lib/gitlab/ci/config/entry/coverage_spec.rb

64 lines
1.4 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'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Ci::Config::Entry::Coverage do
2017-08-17 22:00:37 +05:30
let(:entry) { described_class.new(config) }
describe 'validations' do
context "when entry config value doesn't have the surrounding '/'" do
let(:config) { 'Code coverage: \d+\.\d+' }
describe '#errors' do
subject { entry.errors }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to include(/coverage config must be a regular expression/) }
end
describe '#valid?' do
subject { entry }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.not_to be_valid }
end
end
context "when entry config value has the surrounding '/'" do
let(:config) { '/Code coverage: \d+\.\d+/' }
describe '#value' do
subject { entry.value }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to eq(config[1...-1]) }
end
describe '#errors' do
subject { entry.errors }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_empty }
end
describe '#valid?' do
subject { entry }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to be_valid }
end
end
context 'when entry value is not valid' do
let(:config) { '(malformed regexp' }
describe '#errors' do
subject { entry.errors }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.to include(/coverage config must be a regular expression/) }
end
describe '#valid?' do
subject { entry }
2019-12-21 20:55:43 +05:30
2017-08-17 22:00:37 +05:30
it { is_expected.not_to be_valid }
end
end
end
end