diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-10 13:54:39 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-10 13:54:39 +0200 |
commit | 3c5b1da2a1f15be9e032ec23f56de0af8002ec6b (patch) | |
tree | 3a0ebbeff22b501fac4710999ed2e341eb46fbde /spec | |
parent | 2480701436bf84281e4afd65eb0d4c2d642754b9 (diff) | |
download | gitlab-ce-3c5b1da2a1f15be9e032ec23f56de0af8002ec6b.tar.gz |
Add before_script node to CI job entry config
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/node/job_spec.rb | 46 |
2 files changed, 33 insertions, 15 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 03477e1ca13..230106b74ae 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -970,7 +970,7 @@ EOT config = YAML.dump({ rspec: { script: "test", before_script: [10, "test"] } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: before_script should be an array of strings") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:before_script config should be an array of strings") end it "returns errors if after_script parameter is invalid" do diff --git a/spec/lib/gitlab/ci/config/node/job_spec.rb b/spec/lib/gitlab/ci/config/node/job_spec.rb index f841936ee6b..032fbb9c27f 100644 --- a/spec/lib/gitlab/ci/config/node/job_spec.rb +++ b/spec/lib/gitlab/ci/config/node/job_spec.rb @@ -4,23 +4,15 @@ describe Gitlab::Ci::Config::Node::Job do let(:entry) { described_class.new(config, global: global) } let(:global) { spy('Global') } - describe 'validations' do - before do - entry.process! - entry.validate! - end + before do + entry.process! + entry.validate! + end + describe 'validations' do context 'when entry config value is correct' do let(:config) { { script: 'rspec' } } - describe '#value' do - it 'returns key value' do - expect(entry.value) - .to eq(script: 'rspec', - stage: 'test') - end - end - describe '#valid?' do it 'is valid' do expect(entry).to be_valid @@ -33,7 +25,7 @@ describe Gitlab::Ci::Config::Node::Job do let(:config) { ['incorrect'] } describe '#errors' do - it 'saves errors' do + it 'reports error about a config type' do expect(entry.errors) .to include 'job config should be a hash' end @@ -52,6 +44,32 @@ describe Gitlab::Ci::Config::Node::Job do end end + describe '#value' do + context 'when entry is correct' do + let(:config) do + { before_script: %w[ls pwd], + script: 'rspec' } + end + + it 'returns correct value' do + expect(entry.value) + .to eq(before_script: %w[ls pwd], + script: 'rspec', + stage: 'test') + end + end + + context 'when entry is incorrect' do + let(:config) { {} } + + it 'raises error' do + expect { entry.value }.to raise_error( + Gitlab::Ci::Config::Node::Entry::InvalidError + ) + end + end + end + describe '#relevant?' do it 'is a relevant entry' do expect(entry).to be_relevant |