diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-17 20:23:42 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-18 13:17:48 +0200 |
commit | 2b1c08be8fa5c18f1fe151feb2a0938734086481 (patch) | |
tree | 0fda2e8e739fed60fe9e8c587a7ebf41ceb4c9d2 /spec | |
parent | a2957291b3a28eff3988dfc8bdcff4b99b20a1b3 (diff) | |
download | gitlab-ce-2b1c08be8fa5c18f1fe151feb2a0938734086481.tar.gz |
Validate job-level variables in YAML config file
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 9a014c4b6c6..8813a724774 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -366,22 +366,41 @@ module Ci end context 'when job variables are defined' do - it 'returns job variables' do - variables = { - KEY1: 'value1', - SOME_KEY_2: 'value2' - } + context 'when syntax is correct' do + it 'returns job variables' do + variables = { + KEY1: 'value1', + SOME_KEY_2: 'value2' + } - config = YAML.dump( - { before_script: ['pwd'], - rspec: { - variables: variables, - script: 'rspec' } - }) + config = YAML.dump( + { before_script: ['pwd'], + rspec: { + variables: variables, + script: 'rspec' } + }) - config_processor = GitlabCiYamlProcessor.new(config, path) + config_processor = GitlabCiYamlProcessor.new(config, path) + + expect(config_processor.job_variables(:rspec)).to eq variables + end + end - expect(config_processor.job_variables(:rspec)).to eq variables + context 'when syntax is incorrect' do + it 'raises error' do + variables = [:KEY1, 'value1', :KEY2, 'value2'] + + config = YAML.dump( + { before_script: ['pwd'], + rspec: { + variables: variables, + script: 'rspec' } + }) + + expect { GitlabCiYamlProcessor.new(config, path) } + .to raise_error(GitlabCiYamlProcessor::ValidationError, + /job: variables should be a map/) + end end end |