RSpec::Parameterized syntax for CI pipeline build seed specs
This commit is contained in:
parent
76f49de4e7
commit
d3962bf919
1 changed files with 43 additions and 47 deletions
|
@ -153,76 +153,72 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when keywords and pipeline source policy matches' do
|
context 'with source-keyword policy' do
|
||||||
possibilities = [%w[pushes push],
|
using RSpec::Parameterized
|
||||||
%w[web web],
|
|
||||||
%w[triggers trigger],
|
|
||||||
%w[schedules schedule],
|
|
||||||
%w[api api],
|
|
||||||
%w[external external]]
|
|
||||||
|
|
||||||
context 'when using only' do
|
let(:pipeline) { build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source) }
|
||||||
possibilities.each do |keyword, source|
|
|
||||||
context "when using keyword `#{keyword}` and source `#{source}`" do
|
|
||||||
let(:pipeline) do
|
|
||||||
build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
context 'matches' do
|
||||||
|
where(:keyword, :source) do
|
||||||
|
[
|
||||||
|
%w(pushes push),
|
||||||
|
%w(web web),
|
||||||
|
%w(triggers trigger),
|
||||||
|
%w(schedules schedule),
|
||||||
|
%w(api api),
|
||||||
|
%w(external external)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
with_them do
|
||||||
|
context 'using an only policy' do
|
||||||
let(:attributes) { { name: 'rspec', only: { refs: [keyword] } } }
|
let(:attributes) { { name: 'rspec', only: { refs: [keyword] } } }
|
||||||
|
|
||||||
it { is_expected.to be_included }
|
it { is_expected.to be_included }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when using except' do
|
|
||||||
possibilities.each do |keyword, source|
|
|
||||||
context "when using keyword `#{keyword}` and source `#{source}`" do
|
|
||||||
let(:pipeline) do
|
|
||||||
build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
context 'using an except policy' do
|
||||||
let(:attributes) { { name: 'rspec', except: { refs: [keyword] } } }
|
let(:attributes) { { name: 'rspec', except: { refs: [keyword] } } }
|
||||||
|
|
||||||
it { is_expected.not_to be_included }
|
it { is_expected.not_to be_included }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when keywords and pipeline source does not match' do
|
context 'using both only and except policies' do
|
||||||
possibilities = [%w[pushes web],
|
let(:attributes) { { name: 'rspec', only: { refs: [keyword] }, except: { refs: [keyword] } } }
|
||||||
%w[web push],
|
|
||||||
%w[triggers schedule],
|
|
||||||
%w[schedules external],
|
|
||||||
%w[api trigger],
|
|
||||||
%w[external api]]
|
|
||||||
|
|
||||||
context 'when using only' do
|
|
||||||
possibilities.each do |keyword, source|
|
|
||||||
context "when using keyword `#{keyword}` and source `#{source}`" do
|
|
||||||
let(:pipeline) do
|
|
||||||
build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:attributes) { { name: 'rspec', only: { refs: [keyword] } } }
|
|
||||||
|
|
||||||
it { is_expected.not_to be_included }
|
it { is_expected.not_to be_included }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when using except' do
|
context 'non-matches' do
|
||||||
possibilities.each do |keyword, source|
|
where(:keyword, :source) do
|
||||||
context "when using keyword `#{keyword}` and source `#{source}`" do
|
%w(web trigger schedule api external).map { |source| ['pushes', source] } +
|
||||||
let(:pipeline) do
|
%w(push trigger schedule api external).map { |source| ['web', source] } +
|
||||||
build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
|
%w(push web schedule api external).map { |source| ['triggers', source] } +
|
||||||
end
|
%w(push web trigger api external).map { |source| ['schedules', source] } +
|
||||||
|
%w(push web trigger schedule external).map { |source| ['api', source] } +
|
||||||
|
%w(push web trigger schedule api).map { |source| ['external', source] }
|
||||||
|
end
|
||||||
|
|
||||||
|
with_them do
|
||||||
|
context 'using an only policy' do
|
||||||
|
let(:attributes) { { name: 'rspec', only: { refs: [keyword] } } }
|
||||||
|
|
||||||
|
it { is_expected.not_to be_included }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'using an except policy' do
|
||||||
let(:attributes) { { name: 'rspec', except: { refs: [keyword] } } }
|
let(:attributes) { { name: 'rspec', except: { refs: [keyword] } } }
|
||||||
|
|
||||||
it { is_expected.to be_included }
|
it { is_expected.to be_included }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'using both only and except policies' do
|
||||||
|
let(:attributes) { { name: 'rspec', only: { refs: [keyword] }, except: { refs: [keyword] } } }
|
||||||
|
|
||||||
|
it { is_expected.not_to be_included }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue