# gem install serverspec
will install Serverspec and all dependencies
require 'serverspec'
set :backend, :exec
context 'My first serverspec test' do
describe file('/etc/passwd') do
it { should exist }
it { should be_file }
it { should be_owned_by 'root' }
end
end
$ rspec my_first_test_spec.rb
...
Finished in 0.64969 seconds \
(files took 4.04 seconds to load)
3 examples, 0 failures
$ rspec -f d my_first_test_spec.rb
My first serverspec test
File "/etc/passwd"
should exist
should be file
should be owned by "root"
Finished in 0.76407 seconds \
(files took 3.53 seconds to load)
3 examples, 0 failures
interactive html reports
it { should be_<keyword> [parameter] }
it { should have_<keyword> [parameter] }
its(:content) { should match /regexp/ }