debian-mirror-gitlab/spec/lib/gitlab/ci/config/node/configurable_spec.rb

68 lines
1.4 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe Gitlab::Ci::Config::Node::Configurable do
let(:node) { Class.new }
before do
node.include(described_class)
end
2016-08-24 12:49:21 +05:30
describe 'validations' do
let(:validator) { node.validator.new(instance) }
before do
node.class_eval do
attr_reader :config
def initialize(config)
@config = config
end
end
validator.validate
end
context 'when node validator is invalid' do
let(:instance) { node.new('ls') }
it 'returns invalid validator' do
expect(validator).to be_invalid
end
end
context 'when node instance is valid' do
let(:instance) { node.new(key: 'value') }
it 'returns valid validator' do
expect(validator).to be_valid
end
end
end
describe 'configured nodes' do
before do
node.class_eval do
2016-08-24 12:49:21 +05:30
node :object, Object, description: 'test object'
end
end
2016-08-24 12:49:21 +05:30
describe '.nodes' do
it 'has valid nodes' do
expect(node.nodes).to include :object
end
it 'creates a node factory' do
2016-08-24 12:49:21 +05:30
expect(node.nodes[:object])
.to be_an_instance_of Gitlab::Ci::Config::Node::Factory
end
it 'returns a duplicated factory object' do
2016-08-24 12:49:21 +05:30
first_factory = node.nodes[:object]
second_factory = node.nodes[:object]
expect(first_factory).not_to be_equal(second_factory)
end
end
end
end