Add CI config node that is unspecified null entry

This commit is contained in:
Grzegorz Bizon 2016-07-12 13:03:19 +02:00
parent 8c9c3eda7a
commit d41d330147
2 changed files with 59 additions and 0 deletions

View 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

View 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