As far as I understand, serverspec
is a tool to check servers' configuration state for correctness and make sure that it is in the desired state. This is achieved by logging into the server and executing commands that check given configuration items/values and returns output. So, I have my doubts if serverspec is the right tool for what you want to do.
The site's about section states:
Serverspec tests your servers' actual state by executing command
locally, via SSH, via WinRM, via Docker API and so on.
The only option close to what you are looking for seems to me, is to use the command
resourc type to run and check the ouptput of some commands you wish to. http://serverspec.org/resource_types.html#command
command
Command resource type. its(:stdout), its(:stderr), its(:exit_status)
You can get the stdout, stderr and exit status of the command result,
and can use any matchers RSpec supports.
describe command('ls -al /') do
its(:stdout) { should match /bin/ }
end
describe command('ls /foo') do
its(:stderr) { should match /No such file or directory/ }
end
describe command('ls /foo') do
its(:exit_status) { should eq 0 }
end