Add additional example for matching crontab commands

As raised in #1526, adding an additional example showing how
a user can use the `where` accessor to find commands matching
a pattern and write a test using the results.

Signed-off-by: Adam Leff <adam@leff.co>
This commit is contained in:
Adam Leff 2017-03-13 21:08:41 -05:00 committed by Christoph Hartmann
parent ab9e258112
commit 8155357d0a
2 changed files with 10 additions and 0 deletions

View file

@ -60,3 +60,9 @@ The following examples show how to use this InSpec audit resource.
describe crontab.where({'hour' => '*', 'minute' => '*'}) do
its('entries.length') { should cmp '0' }
end
### Test that the logged-in user's crontab contains a single command that matches a mattern
describe crontab.where { command =~ /a partial command string/ } do
its('entries.length') { should cmp 1 }
end

View file

@ -21,6 +21,10 @@ module Inspec::Resources
describe crontab.where({'hour' => '*', 'minute' => '*'}) do
its('entries.length') { should cmp '0' }
end
describe crontab.where { command =~ /a partial command string/ } do
its('entries.length') { should cmp 1 }
end
"
attr_reader :params