Add CI config node that is unspecified null entry
This commit is contained in:
parent
8c9c3eda7a
commit
d41d330147
2 changed files with 59 additions and 0 deletions
30
lib/gitlab/ci/config/node/null.rb
Normal file
30
lib/gitlab/ci/config/node/null.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Gitlab
|
||||
module Ci
|
||||
class Config
|
||||
module Node
|
||||
##
|
||||
# This class represents an undefined and unspecified node.
|
||||
#
|
||||
# Implements the Null Object pattern.
|
||||
#
|
||||
class Null < Entry
|
||||
def initialize(config = nil, **attributes)
|
||||
super
|
||||
end
|
||||
|
||||
def value
|
||||
nil
|
||||
end
|
||||
|
||||
def valid?
|
||||
true
|
||||
end
|
||||
|
||||
def errors
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
29
spec/lib/gitlab/ci/config/node/null_spec.rb
Normal file
29
spec/lib/gitlab/ci/config/node/null_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Ci::Config::Node::Null do
|
||||
let(:null) { described_class.new }
|
||||
|
||||
describe '#leaf?' do
|
||||
it 'is leaf node' do
|
||||
expect(null).to be_leaf
|
||||
end
|
||||
end
|
||||
|
||||
describe '#valid?' do
|
||||
it 'is always valid' do
|
||||
expect(null).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe '#errors' do
|
||||
it 'is does not contain errors' do
|
||||
expect(null.errors).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
describe '#value' do
|
||||
it 'returns nil' do
|
||||
expect(null.value).to eq nil
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue