blob: 3ed4a9f263f1d861dc274d781a57b28d3670615d (
plain)
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
76
77
78
79
80
81
|
# frozen_string_literal: true
require 'fast_spec_helper'
RSpec.describe Gitlab::Ci::Config::Entry::Rules::Rule::Changes do
let(:factory) do
Gitlab::Config::Entry::Factory.new(described_class)
.value(config)
end
subject(:entry) { factory.create! }
before do
entry.compose!
end
describe '.new' do
context 'when using a string array' do
let(:config) { %w[app/ lib/ spec/ other/* paths/**/*.rb] }
it { is_expected.to be_valid }
end
context 'when using an integer array' do
let(:config) { [1, 2] }
it { is_expected.not_to be_valid }
it 'returns errors' do
expect(entry.errors).to include(/changes config should be an array of strings/)
end
end
context 'when using a string' do
let(:config) { 'a regular string' }
it { is_expected.not_to be_valid }
it 'reports an error about invalid policy' do
expect(entry.errors).to include(/should be an array of strings/)
end
end
context 'when using a long array' do
let(:config) { ['app/'] * 51 }
it { is_expected.not_to be_valid }
it 'returns errors' do
expect(entry.errors).to include(/has too many entries \(maximum 50\)/)
end
end
context 'when clause is empty' do
let(:config) {}
it { is_expected.to be_valid }
end
context 'when policy strategy does not match' do
let(:config) { 'string strategy' }
it { is_expected.not_to be_valid }
it 'returns information about errors' do
expect(entry.errors)
.to include(/should be an array of strings/)
end
end
end
describe '#value' do
subject(:value) { entry.value }
context 'when using a string array' do
let(:config) { %w[app/ lib/ spec/ other/* paths/**/*.rb] }
it { is_expected.to eq(config) }
end
end
end
|