mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
Fix YAML resource documentation
The `yaml` resource documentation was missing many clues that users need to successfully use the resource. Signed-off-by: Adam Leff <adam@leff.co>
This commit is contained in:
parent
ff082e12c7
commit
bc2458bf5a
2 changed files with 25 additions and 3 deletions
|
@ -17,7 +17,7 @@ A `yaml` resource block declares the configuration data to be tested. Assume the
|
|||
|
||||
This file can be queried using:
|
||||
|
||||
describe yaml do
|
||||
describe yaml('filename.yml') do
|
||||
its('name') { should eq 'foo' }
|
||||
its(['array', 1]) { should eq 'one' }
|
||||
end
|
||||
|
@ -27,6 +27,20 @@ where
|
|||
* `name` is a configuration setting in a Yaml file
|
||||
* `should eq 'foo'` tests a value of `name` as read from a Yaml file versus the value declared in the test
|
||||
|
||||
Like the `json` resource, the `yaml` resource can read a file, run a command, or accept content inline:
|
||||
|
||||
describe yaml('config.yaml') do
|
||||
its(['driver', 'name']) { should eq 'vagrant' }
|
||||
end
|
||||
|
||||
describe yaml({ command: 'retrieve_data.py --yaml' }) do
|
||||
its('state') { should eq 'open' }
|
||||
end
|
||||
|
||||
describe yaml({ content: \"key1: value1\nkey2: value2\" }) do
|
||||
its('key2') { should cmp 'value2' }
|
||||
end
|
||||
|
||||
|
||||
## Matchers
|
||||
|
||||
|
|
|
@ -14,8 +14,16 @@ module Inspec::Resources
|
|||
name 'yaml'
|
||||
desc 'Use the yaml InSpec audit resource to test configuration data in a YAML file.'
|
||||
example "
|
||||
describe yaml do
|
||||
its('name') { should eq 'foo' }
|
||||
describe yaml('config.yaml') do
|
||||
its(['driver', 'name']) { should eq 'vagrant' }
|
||||
end
|
||||
|
||||
describe yaml({ command: 'retrieve_data.py --yaml' }) do
|
||||
its('state') { should eq 'open' }
|
||||
end
|
||||
|
||||
describe yaml({ content: \"key1: value1\nkey2: value2\" }) do
|
||||
its('key2') { should cmp 'value2' }
|
||||
end
|
||||
"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue