Document additional usage of json resource

The `command` and `content` usage seems to have been supported for some time, but is not included in the documentation.

ref:
* https://github.com/inspec/inspec/pull/1271

Signed-off-by: Sean Escriva <sean.escriva@gmail.com>
This commit is contained in:
Sean Escriva 2019-01-20 15:12:28 -05:00
parent e6abd1b23e
commit b764ced5d9
No known key found for this signature in database
GPG key ID: BE06ADB38C7F719D

View file

@ -47,6 +47,21 @@ where
* `name` is a configuration setting in a JSON file
* `should eq 'foo'` tests a value of `name` as read from a JSON file versus the value declared in the test
The `json` resource can also be used with json formatted output from a command.
Using the same json as the previous exmaple, it can be queried using:
describe json({ command: 'retrieve_data.py --json'}) do
its('name') { should eq 'hello' }
its(['meta','creator']) { should eq 'John Doe' }
its(['array', 1]) { should eq 'one' }
end
Finally content can be passed directly to the resource:
describe json({ content: '{\"item1\": { \"status\": \"available\" } }' }) do
its(['item1', 'status']) { should cmp 'available' }
end
<br>
## Examples