diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-24 09:54:52 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-24 09:54:52 +0200 |
commit | ce4478ed86e7487ea6bb45703561d1d5539ef5b4 (patch) | |
tree | 87d42d57114d3f517c07ab0504d81d1bada760dd | |
parent | e017e1b62904fe323be359f1ac406c951dcd4ccd (diff) | |
download | gitlab-ce-ce4478ed86e7487ea6bb45703561d1d5539ef5b4.tar.gz |
Add ci config entry that represents array of paths
-rw-r--r-- | lib/gitlab/ci/config/node/paths.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/node/paths_spec.rb | 34 |
2 files changed, 52 insertions, 0 deletions
diff --git a/lib/gitlab/ci/config/node/paths.rb b/lib/gitlab/ci/config/node/paths.rb new file mode 100644 index 00000000000..3c6d3a52966 --- /dev/null +++ b/lib/gitlab/ci/config/node/paths.rb @@ -0,0 +1,18 @@ +module Gitlab + module Ci + class Config + module Node + ## + # Entry that represents an array of paths. + # + class Paths < Entry + include Validatable + + validations do + validates :config, array_of_strings: true + end + end + end + end + end +end diff --git a/spec/lib/gitlab/ci/config/node/paths_spec.rb b/spec/lib/gitlab/ci/config/node/paths_spec.rb new file mode 100644 index 00000000000..0d95ad8abda --- /dev/null +++ b/spec/lib/gitlab/ci/config/node/paths_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe Gitlab::Ci::Config::Node::Paths do + let(:entry) { described_class.new(config) } + + describe 'validations' do + context 'when entry config value is valid' do + let(:config) { ['some/file', 'some/path/'] } + + describe '#value' do + it 'returns key value' do + expect(entry.value).to eq config + end + end + + describe '#valid?' do + it 'is valid' do + expect(entry).to be_valid + end + end + end + + context 'when entry value is not valid' do + let(:config) { [ 1 ] } + + describe '#errors' do + it 'saves errors' do + expect(entry.errors) + .to include 'Paths config should be an array of strings' + end + end + end + end +end |