summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-06-24 12:11:22 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2019-06-24 12:11:22 +0000
commit77b2e8a2e460e15155b2cadea1a14f9438879c2c (patch)
tree5abd048c152c8de08b5ca83652e47c133db33e1e
parent88c8d177f835983a0a47796529906c69376d159d (diff)
parentd3962bf9198d386b4c662f7b184cc53346854834 (diff)
downloadgitlab-ce-77b2e8a2e460e15155b2cadea1a14f9438879c2c.tar.gz
Merge branch 'ci-pipeline-build-seed-spec-refactor' into 'master'
RSpec::Parameterized syntax for CI pipeline build seed specs See merge request gitlab-org/gitlab-ce!29947
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build_spec.rb90
1 files changed, 43 insertions, 47 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
index fae8add6453..7991e2f48b5 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
@@ -153,76 +153,72 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
- context 'when keywords and pipeline source policy matches' do
- possibilities = [%w[pushes push],
- %w[web web],
- %w[triggers trigger],
- %w[schedules schedule],
- %w[api api],
- %w[external external]]
-
- 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
+ context 'with source-keyword policy' do
+ using RSpec::Parameterized
+
+ let(:pipeline) { build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source) }
+
+ 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] } } }
it { is_expected.to be_included }
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] } } }
it { is_expected.not_to be_included }
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
- context 'when keywords and pipeline source does not match' do
- possibilities = [%w[pushes web],
- %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
+ context 'non-matches' do
+ where(:keyword, :source) do
+ %w(web trigger schedule api external).map { |source| ['pushes', source] } +
+ %w(push trigger schedule api external).map { |source| ['web', source] } +
+ %w(push web schedule api external).map { |source| ['triggers', source] } +
+ %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
- 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] } } }
it { is_expected.to be_included }
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