I just wonder is there some tools like Guard gem compatible with chef/inspec (https://github.com/guard/guard).
Guard is configured with a Guardfile that tells it which directories and files to monitor, and what command to run when they change.
So I’d love to run a test suite when spec files are changed.
Do you know any tools like this?
The Guard project definitely will definitely work. Consider using guard-shell. It’s generic and when file events are generated you can run a command on that particular file or the entire profile.
$ guard init shell
~/myprofile/Guardfile
command = "inspec exec"
target = "-t TARGET_INSTANCE"
guard :shell do
watch /controls\/.+\.rb/ do |m|
m[0] + " has changed."
`#{command} #{m[0]} #{target}`
end
watch /inspec\.yml/ do
`#{command} . #{target}`
end
end
The first guard will check to see if a Ruby file within the controls directory changed. If it does execute the command inspec exec control/FILENAME.rb -t TARGET_INSTANCE. The second guard will watch to see if the `inspec.yml’ file changes and run the entire profile.
This could be refined a bit but I think this hopefully conveys an approach.