add yaml resource

This commit is contained in:
Christoph Hartmann 2015-09-21 09:51:54 +02:00 committed by Dominik Richter
parent 0e43d4ca6a
commit b9d4fc6d8c
5 changed files with 43 additions and 0 deletions

15
lib/resources/yaml.rb Normal file
View file

@ -0,0 +1,15 @@
# encoding: utf-8
# Parses a yaml document
# Usage:
# describe yaml('.kitchen.yaml') do
# its('driver.name') { should eq('vagrant') }
# end
class YamlConfig < JsonConfig
name 'yaml'
# override file load and parse hash from yaml
def parse(content)
YAML.load(content)
end
end

View file

@ -56,4 +56,5 @@ require 'resources/security_policy'
require 'resources/service'
require 'resources/ssh_conf'
require 'resources/windows_feature'
require 'resources/yaml'
require 'resources/yum'

View file

@ -44,6 +44,7 @@ def loadResource (resource, *args)
'/etc/audit/auditd.conf' => mockfile.('auditd.conf'),
'/etc/mysql/my.cnf' => mockfile.('mysql.conf'),
'/etc/mysql/mysql2.conf' => mockfile.('mysql2.conf'),
'kitchen.yml' => mockfile.('kitchen.yml'),
'policyfile.lock.json' => mockfile.('policyfile.lock.json'),
}

View file

@ -0,0 +1,7 @@
driver:
name: vagrant
customize:
memory: 1024
platforms:
- name: centos-5.11
- name: centos-6.7

View file

@ -0,0 +1,19 @@
# encoding: utf-8
require 'helper'
require 'vulcano/resource'
describe 'Vulcano:Resources::YAML' do
describe 'yaml' do
let(:resource) { loadResource('yaml', 'kitchen.yml') }
it 'verify yaml parsing' do
_(resource.params).wont_be_nil
_(resource.send('driver.name')).must_equal 'vagrant'
_(resource.send('driver.customize.memory')).must_equal 1024
_(resource.send('platforms.1.name')).must_equal 'centos-6.7'
_(resource.send('platforms.name')).must_equal %w{centos-5.11 centos-6.7}
end
end
end