2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-06 06:58:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Gitlab::Ci::Config::Entry::Hidden do
|
2019-06-18 06:36:07 -04:00
|
|
|
describe '.matching?' do
|
|
|
|
subject { described_class.matching?(name, {}) }
|
2016-07-06 06:58:43 -04:00
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
context 'when name starts with dot' do
|
|
|
|
let(:name) { '.hidden_job' }
|
2016-07-06 06:58:43 -04:00
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
it { is_expected.to be_truthy }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when name does not start with dot' do
|
|
|
|
let(:name) { 'rspec' }
|
|
|
|
|
|
|
|
it { is_expected.to be_falsey }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.new' do
|
|
|
|
let(:entry) { described_class.new(config) }
|
|
|
|
|
|
|
|
describe 'validations' do
|
|
|
|
context 'when entry config value is correct' do
|
|
|
|
let(:config) { [:some, :array] }
|
|
|
|
|
|
|
|
describe '#value' do
|
|
|
|
it 'returns key value' do
|
|
|
|
expect(entry.value).to eq [:some, :array]
|
|
|
|
end
|
2016-07-06 06:58:43 -04:00
|
|
|
end
|
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
describe '#valid?' do
|
|
|
|
it 'is valid' do
|
|
|
|
expect(entry).to be_valid
|
|
|
|
end
|
2016-07-06 06:58:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
context 'when entry value is not correct' do
|
|
|
|
context 'when config is empty' do
|
|
|
|
let(:config) { {} }
|
2016-07-09 12:43:26 -04:00
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
describe '#valid' do
|
|
|
|
it 'is invalid' do
|
|
|
|
expect(entry).not_to be_valid
|
|
|
|
end
|
2016-07-09 12:43:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-07-06 06:58:43 -04:00
|
|
|
end
|
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
describe '#leaf?' do
|
|
|
|
it 'is a leaf' do
|
|
|
|
expect(entry).to be_leaf
|
|
|
|
end
|
2016-07-06 06:58:43 -04:00
|
|
|
end
|
|
|
|
|
2019-06-18 06:36:07 -04:00
|
|
|
describe '#relevant?' do
|
|
|
|
it 'is not a relevant entry' do
|
|
|
|
expect(entry).not_to be_relevant
|
|
|
|
end
|
2016-07-06 06:58:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|