Commit d3962bf9 authored by drew cimino's avatar drew cimino

RSpec::Parameterized syntax for CI pipeline build seed specs

parent 76f49de4
...@@ -153,76 +153,72 @@ describe Gitlab::Ci::Pipeline::Seed::Build do ...@@ -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], let(:pipeline) { build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source) }
%w[schedules schedule],
%w[api api], context 'matches' do
%w[external external]] where(:keyword, :source) do
[
context 'when using only' do %w(pushes push),
possibilities.each do |keyword, source| %w(web web),
context "when using keyword `#{keyword}` and source `#{source}`" do %w(triggers trigger),
let(:pipeline) do %w(schedules schedule),
build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source) %w(api api),
end %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
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
context 'when keywords and pipeline source does not match' do context 'non-matches' do
possibilities = [%w[pushes web], where(:keyword, :source) do
%w[web push], %w(web trigger schedule api external).map { |source| ['pushes', source] } +
%w[triggers schedule], %w(push trigger schedule api external).map { |source| ['web', source] } +
%w[schedules external], %w(push web schedule api external).map { |source| ['triggers', source] } +
%w[api trigger], %w(push web trigger api external).map { |source| ['schedules', source] } +
%w[external api]] %w(push web trigger schedule external).map { |source| ['api', source] } +
%w(push web trigger schedule api).map { |source| ['external', source] }
context 'when using only' do end
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
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.not_to be_included } it { is_expected.not_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.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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment