Skip to content

Instantly share code, notes, and snippets.

@amaltson
Forked from neilhwatson/gist:81249ad393800a76a8ad
Last active August 29, 2015 14:21
Show Gist options
  • Save amaltson/e54da0f6b5f9cc06a8dd to your computer and use it in GitHub Desktop.
Save amaltson/e54da0f6b5f9cc06a8dd to your computer and use it in GitHub Desktop.
Rakefile:
require 'rake'
require 'rspec/core/rake_task'
hosts = %w(
atlspf01
atlspf02
atlspf03
atlspf04
)
task :spec => 'spec:all'
namespace :spec do
task :all => hosts.map {|h| 'spec:' + h.split('.')[0] }
hosts.each do |host|
begin
desc "Run serverspec to #{host}"
RSpec::Core::RakeTask.new(host) do |t|
ENV['TARGET_HOST'] = host
t.pattern = "spec/base,cfengine3/*_spec.rb"
end
rescue
end
end
end
Spec file:
require 'spec_helper'
before(:all) do
puts "ServerSpec tests on #{ENV['TARGET_HOST']}"
end
describe package('cfengine-community') do
it { should be_installed }
end
describe command( '/var/cfengine/bin/cf-promises --version') do
its(:stdout) { should match /3\.6\.5/ }
end
describe service( 'cfengine3' ) do
it { should be_enabled }
end
[ 'execd', 'serverd', 'monitord' ].each |proc|
describe process( "cf-#{proc}" ) do
it { should be_running }
end
end
describe port(5308) do
it { should be_listening }
end
Results (what host failed?)
$ rspec
Password:
..F....
Failures:
1) Service "cfengine3" should be enabled
Failure/Error: it { should be_enabled }
expected Service "cfengine3" to be enabled
sudo -p 'Password: ' /bin/sh -c chkconfig\ --list\ cfengine3\ \|\ grep\ 3:on
# ./spec/cfengine3/common_spec.rb:12:in `block (2 levels) in <top (required)>'
Finished in 10.76 seconds (files took 4.66 seconds to load)
7 examples, 1 failure
Failed examples:
rspec ./spec/cfengine3/common_spec.rb:12 # Service "cfengine3" should be enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment