summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-06-01 15:46:15 +0900
committerShinya Maeda <shinya@gitlab.com>2018-06-01 15:46:15 +0900
commitc89e57842ebf7f395363bcddaeff76bc7b3f7890 (patch)
tree5ca5821962a84aa6b378974dfee768825d93bb18
parentc418d68765eb09c468419ec8f438100cda64a0d4 (diff)
downloadgitlab-ce-c89e57842ebf7f395363bcddaeff76bc7b3f7890.tar.gz
Use shared examples for populate spec
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb34
-rw-r--r--spec/support/shared_examples/models/atomic_internal_id_spec.rb4
2 files changed, 18 insertions, 20 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
index ffb2c1d5b0c..7088233f237 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
@@ -157,6 +157,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end
context 'when variables policy is specified' do
+ shared_examples_for 'populates pipeline according to used policies' do
+ it 'populates pipeline according to used policies' do
+ step.perform!
+
+ expect(pipeline.stages.size).to eq 1
+ expect(pipeline.stages.first.builds.size).to eq 1
+ expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
+ end
+ end
+
context 'when using only/except build policies' do
let(:config) do
{ rspec: { script: 'rspec', stage: 'test', only: ['master'] },
@@ -167,28 +177,16 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
build(:ci_pipeline, ref: 'master', config: config)
end
- it 'populates pipeline according to used policies' do
- step.perform!
-
- expect(pipeline.stages.size).to eq 1
- expect(pipeline.stages.first.builds.size).to eq 1
- expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
- end
+ it_behaves_like 'populates pipeline according to used policies'
context 'when variables expression is specified' do
- let(:config) do
- { rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } },
- prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } }
- end
-
context 'when pipeline iid is the subject' do
- it 'populates pipeline according to used policies' do
- step.perform!
-
- expect(pipeline.stages.size).to eq 1
- expect(pipeline.stages.first.builds.size).to eq 1
- expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
+ let(:config) do
+ { rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } },
+ prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } }
end
+
+ it_behaves_like 'populates pipeline according to used policies'
end
end
end
diff --git a/spec/support/shared_examples/models/atomic_internal_id_spec.rb b/spec/support/shared_examples/models/atomic_internal_id_spec.rb
index d0cd8da67e1..7ab1041d17c 100644
--- a/spec/support/shared_examples/models/atomic_internal_id_spec.rb
+++ b/spec/support/shared_examples/models/atomic_internal_id_spec.rb
@@ -15,7 +15,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
instance.valid?
end
- context 'when presence validattion is required' do
+ context 'when presence validation is required' do
before do
skip unless validate_presence
end
@@ -25,7 +25,7 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
end
end
- context 'when presence validattion is not required' do
+ context 'when presence validation is not required' do
before do
skip if validate_presence
end