summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/ci/config/extendable
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-08-17 10:07:38 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-09-04 14:17:01 +0200
commitee9fd5c226fcf83b8a4a0bf2814c9d0efc530659 (patch)
tree8de152254815e2762e66b0dd2989324b300e5b15 /spec/lib/gitlab/ci/config/extendable
parent2f05e34b3c909aaf0d31ab6e10809bf3d0fc6626 (diff)
downloadgitlab-ce-ee9fd5c226fcf83b8a4a0bf2814c9d0efc530659.tar.gz
Improve extendable CI/CD config hash collection
Diffstat (limited to 'spec/lib/gitlab/ci/config/extendable')
-rw-r--r--spec/lib/gitlab/ci/config/extendable/collection_spec.rb37
1 files changed, 18 insertions, 19 deletions
diff --git a/spec/lib/gitlab/ci/config/extendable/collection_spec.rb b/spec/lib/gitlab/ci/config/extendable/collection_spec.rb
index 08c929ef70d..796683fea63 100644
--- a/spec/lib/gitlab/ci/config/extendable/collection_spec.rb
+++ b/spec/lib/gitlab/ci/config/extendable/collection_spec.rb
@@ -13,23 +13,13 @@ describe Gitlab::Ci::Config::Extendable::Collection do
{ something: { script: 'ls' }, test: test }
end
- it 'yields the test hash' do
- expect { |b| subject.each(&b) }.to yield_control
- end
- end
-
- context 'when not extending using a hash' do
- let(:hash) do
- { something: { extends: [1], script: 'ls' } }
- end
-
- it 'yields invalid extends as well' do
+ it 'yields control' do
expect { |b| subject.each(&b) }.to yield_control
end
end
end
- describe '#extend!' do
+ describe '#to_hash' do
context 'when a hash has a single simple extension' do
let(:hash) do
{
@@ -47,7 +37,7 @@ describe Gitlab::Ci::Config::Extendable::Collection do
end
it 'extends a hash with a deep reverse merge' do
- expect(subject.extend!).to eq(
+ expect(subject.to_hash).to eq(
something: {
script: 'deploy',
only: { variables: %w[$SOMETHING] }
@@ -88,7 +78,7 @@ describe Gitlab::Ci::Config::Extendable::Collection do
end
it 'extends a hash with a deep reverse merge' do
- expect(subject.extend!).to eq(
+ expect(subject.to_hash).to eq(
'.first': {
script: 'run',
only: { kubernetes: 'active' }
@@ -139,8 +129,8 @@ describe Gitlab::Ci::Config::Extendable::Collection do
}
end
- it 'raises an error' do
- expect { subject.extend! }
+ it 'raises an error about circular dependency' do
+ expect { subject.to_hash }
.to raise_error(described_class::CircularDependencyError)
end
end
@@ -156,12 +146,21 @@ describe Gitlab::Ci::Config::Extendable::Collection do
}
end
- it 'raises an error' do
- expect { subject.extend! }
+ it 'raises an error about circular dependency' do
+ expect { subject.to_hash }
.to raise_error(described_class::CircularDependencyError)
end
end
- pending 'when invalid `extends` is specified'
+ context 'when invalid extends value is specified' do
+ let(:hash) do
+ { something: { extends: 1, script: 'ls' } }
+ end
+
+ it 'raises an error about invalid extension' do
+ expect { subject.to_hash }
+ .to raise_error(described_class::InvalidExtensionError)
+ end
+ end
end
end