mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
add yaml resource
This commit is contained in:
parent
0e43d4ca6a
commit
b9d4fc6d8c
5 changed files with 43 additions and 0 deletions
15
lib/resources/yaml.rb
Normal file
15
lib/resources/yaml.rb
Normal 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
|
|
@ -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'
|
||||
|
|
|
@ -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'),
|
||||
}
|
||||
|
||||
|
|
7
test/unit/mock/files/kitchen.yml
Normal file
7
test/unit/mock/files/kitchen.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
driver:
|
||||
name: vagrant
|
||||
customize:
|
||||
memory: 1024
|
||||
platforms:
|
||||
- name: centos-5.11
|
||||
- name: centos-6.7
|
19
test/unit/resource_yaml_test.rb
Normal file
19
test/unit/resource_yaml_test.rb
Normal 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
|
Loading…
Reference in a new issue