summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-15 21:07:51 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-07-15 21:07:51 +0200
commit41bcbdd8c2412769a376cd37541ad6e65a1af1f2 (patch)
tree09a1a1ba53ef8dcfe17e6851c0937052a2f2f77a /spec/lib
parent615c9730e7783e82287d2b65f58da6336d3d2410 (diff)
downloadgitlab-ce-41bcbdd8c2412769a376cd37541ad6e65a1af1f2.tar.gz
Add metadata to new CI config and expose job name
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/config/node/factory_spec.rb37
-rw-r--r--spec/lib/gitlab/ci/config/node/global_spec.rb13
-rw-r--r--spec/lib/gitlab/ci/config/node/job_spec.rb9
-rw-r--r--spec/lib/gitlab/ci/config/node/jobs_spec.rb12
4 files changed, 34 insertions, 37 deletions
diff --git a/spec/lib/gitlab/ci/config/node/factory_spec.rb b/spec/lib/gitlab/ci/config/node/factory_spec.rb
index 4e6f2419e13..d26185ba585 100644
--- a/spec/lib/gitlab/ci/config/node/factory_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/factory_spec.rb
@@ -4,32 +4,20 @@ describe Gitlab::Ci::Config::Node::Factory do
describe '#create!' do
let(:factory) { described_class.new(node) }
let(:node) { Gitlab::Ci::Config::Node::Script }
- let(:parent) { double('parent') }
context 'when setting a concrete value' do
it 'creates entry with valid value' do
entry = factory
.value(['ls', 'pwd'])
- .parent(parent)
.create!
expect(entry.value).to eq ['ls', 'pwd']
end
- it 'sets parent attributes' do
- entry = factory
- .value('ls')
- .parent(parent)
- .create!
-
- expect(entry.parent).to eq parent
- end
-
context 'when setting description' do
it 'creates entry with description' do
entry = factory
.value(['ls', 'pwd'])
- .parent(parent)
.with(description: 'test description')
.create!
@@ -42,7 +30,6 @@ describe Gitlab::Ci::Config::Node::Factory do
it 'creates entry with custom key' do
entry = factory
.value(['ls', 'pwd'])
- .parent(parent)
.with(key: 'test key')
.create!
@@ -56,7 +43,6 @@ describe Gitlab::Ci::Config::Node::Factory do
it 'creates entry with valid parent' do
entry = factory
.value('ls')
- .parent(parent)
.with(parent: object)
.create!
@@ -73,23 +59,28 @@ describe Gitlab::Ci::Config::Node::Factory do
end
end
- context 'when not setting parent object' do
- it 'raises error' do
- expect { factory.value('ls').create! }.to raise_error(
- Gitlab::Ci::Config::Node::Factory::InvalidFactory
- )
- end
- end
-
context 'when creating entry with nil value' do
it 'creates an undefined entry' do
entry = factory
.value(nil)
- .parent(parent)
.create!
expect(entry).to be_an_instance_of Gitlab::Ci::Config::Node::Undefined
end
end
+
+ context 'when passing metadata' do
+ let(:node) { spy('node') }
+
+ it 'passes metadata as a parameter' do
+ factory
+ .value('some value')
+ .metadata(some: 'hash')
+ .create!
+
+ expect(node).to have_received(:new)
+ .with('some value', { some: 'hash' })
+ end
+ end
end
end
diff --git a/spec/lib/gitlab/ci/config/node/global_spec.rb b/spec/lib/gitlab/ci/config/node/global_spec.rb
index dfcaebe35be..2a071b57c72 100644
--- a/spec/lib/gitlab/ci/config/node/global_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/global_spec.rb
@@ -128,11 +128,14 @@ describe Gitlab::Ci::Config::Node::Global do
describe '#jobs' do
it 'returns jobs configuration' do
- expect(global.jobs)
- .to eq(rspec: { script: %w[rspec ls],
- stage: 'test' },
- spinach: { script: %w[spinach],
- stage: 'test' })
+ expect(global.jobs).to eq(
+ rspec: { name: :rspec,
+ script: %w[rspec ls],
+ stage: 'test' },
+ spinach: { name: :spinach,
+ script: %w[spinach],
+ stage: 'test' }
+ )
end
end
end
diff --git a/spec/lib/gitlab/ci/config/node/job_spec.rb b/spec/lib/gitlab/ci/config/node/job_spec.rb
index 4c7ac9949cc..b2559e6e73c 100644
--- a/spec/lib/gitlab/ci/config/node/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/job_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Gitlab::Ci::Config::Node::Job do
- let(:entry) { described_class.new(config, key: :rspec) }
+ let(:entry) { described_class.new(config, name: :rspec) }
before do
entry.process!
@@ -19,7 +19,7 @@ describe Gitlab::Ci::Config::Node::Job do
end
context 'when job name is empty' do
- let(:entry) { described_class.new(config, key: ''.to_sym) }
+ let(:entry) { described_class.new(config, name: ''.to_sym) }
it 'reports error' do
expect(entry.errors)
@@ -35,7 +35,7 @@ describe Gitlab::Ci::Config::Node::Job do
describe '#errors' do
it 'reports error about a config type' do
expect(entry.errors)
- .to include 'rspec config should be a hash'
+ .to include 'job config should be a hash'
end
end
end
@@ -62,7 +62,8 @@ describe Gitlab::Ci::Config::Node::Job do
it 'returns correct value' do
expect(entry.value)
- .to eq(before_script: %w[ls pwd],
+ .to eq(name: :rspec,
+ before_script: %w[ls pwd],
script: %w[rspec],
stage: 'test',
after_script: %w[cleanup])
diff --git a/spec/lib/gitlab/ci/config/node/jobs_spec.rb b/spec/lib/gitlab/ci/config/node/jobs_spec.rb
index c4c130abb6d..4f08f2f9b69 100644
--- a/spec/lib/gitlab/ci/config/node/jobs_spec.rb
+++ b/spec/lib/gitlab/ci/config/node/jobs_spec.rb
@@ -61,11 +61,13 @@ describe Gitlab::Ci::Config::Node::Jobs do
describe '#value' do
it 'returns key value' do
- expect(entry.value)
- .to eq(rspec: { script: %w[rspec],
- stage: 'test' },
- spinach: { script: %w[spinach],
- stage: 'test' })
+ expect(entry.value).to eq(
+ rspec: { name: :rspec,
+ script: %w[rspec],
+ stage: 'test' },
+ spinach: { name: :spinach,
+ script: %w[spinach],
+ stage: 'test' })
end
end