inspec/docs/resources/csv.md.erb

63 lines
1.1 KiB
Text
Raw Normal View History

2016-09-22 12:43:57 +00:00
---
title: About the csv Resource
---
# csv
Use the `csv` InSpec audit resource to test configuration data in a CSV file.
## Syntax
2016-09-22 12:43:57 +00:00
A `csv` resource block declares the configuration data to be tested:
describe csv('file') do
its('name') { should eq 'foo' }
end
where
* `'file'` is the path to a CSV file
* `name` is a configuration setting in a CSV file
* `should eq 'foo'` tests a value of `name` as read from a CSV file versus the value declared in the test
## Matchers
2016-09-22 12:43:57 +00:00
This InSpec audit resource has the following matchers:
### be
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_be" %>
### cmp
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_cmp" %>
### eq
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_eq" %>
### include
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_include" %>
### match
2016-09-22 12:43:57 +00:00
<%= partial "/shared/matcher_match" %>
### name
2016-09-22 12:43:57 +00:00
The `name` matcher tests the value of `name` as read from a CSV file versus the value declared in the test:
its('name') { should eq 'foo' }
## Examples
2016-09-22 12:43:57 +00:00
The following examples show how to use this InSpec audit resource.
### Test a CSV file
2016-09-22 12:43:57 +00:00
describe csv('some_file.csv') do
its('setting') { should eq 1 }
end