summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-10 13:54:39 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-10 13:54:39 +0200
commit3c5b1da2a1f15be9e032ec23f56de0af8002ec6b (patch)
tree3a0ebbeff22b501fac4710999ed2e341eb46fbde /spec/lib/gitlab
parent2480701436bf84281e4afd65eb0d4c2d642754b9 (diff)
downloadgitlab-ce-3c5b1da2a1f15be9e032ec23f56de0af8002ec6b.tar.gz
Add before_script node to CI job entry config
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/ci/config/node/job_spec.rb46
1 files changed, 32 insertions, 14 deletions
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