diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-08-16 12:25:13 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-09-04 14:17:00 +0200 |
commit | 5b9a6ca00a023493c750f9d4a3b06729fdc96fff (patch) | |
tree | 7fb2ed3bb76289f9c0fc5147d2b8896bbfc68175 /spec/lib/gitlab/ci | |
parent | afb49b044bcb71702edd3f5ef0139599ddc54ef5 (diff) | |
download | gitlab-ce-5b9a6ca00a023493c750f9d4a3b06729fdc96fff.tar.gz |
Add basic support for CI/CD config extension
Diffstat (limited to 'spec/lib/gitlab/ci')
-rw-r--r-- | spec/lib/gitlab/ci/config/extendable_spec.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/config/extendable_spec.rb b/spec/lib/gitlab/ci/config/extendable_spec.rb new file mode 100644 index 00000000000..a23fe560202 --- /dev/null +++ b/spec/lib/gitlab/ci/config/extendable_spec.rb @@ -0,0 +1,63 @@ +require 'fast_spec_helper' + +describe Gitlab::Ci::Config::Extendable do + subject { described_class.new(hash) } + + describe '#each' do + context 'when there is extendable entry in the hash' do + let(:test) do + { extends: 'something', only: %w[master] } + end + + let(:hash) do + { something: { script: 'ls' }, test: test } + end + + it 'yields the test hash' do + expect { |b| subject.each(&b) } + .to yield_with_args(:test, :something, test) + end + end + + pending 'when not extending using a hash' + end + + describe '#extend!' do + context 'when a hash has a single simple extension' do + let(:hash) do + { + something: { + script: 'deploy', + only: { variables: %w[$SOMETHING] } + }, + test: { + extends: 'something', + script: 'ls', + only: { refs: %w[master] } + } + } + end + + it 'extends a hash with reverse merge' do + expect(subject.extend!).to eq( + something: { + script: 'deploy', + only: { variables: %w[$SOMETHING] } + }, + test: { + extends: 'something', + script: 'ls', + only: { + refs: %w[master], + variables: %w[$SOMETHING] + } + } + ) + end + end + + pending 'when a hash recursive extensions' + + pending 'when invalid `extends` is specified' + end +end |