41. 40
require 'rubygems'
require 'spec_helper'
describe package('httpd'), :if => os[:family] == 'redhat' do
it { should be_installed }
end
describe service('httpd'), :if => os[:family] == 'redhat' do
it { should be_enabled }
it { should be_running }
end
describe port(80) do
it { should be_listening }
end
テストケースサンプル
(一部抜粋)
42. 41
# rake spec
Service "httpd"
should be enabled
should be running
Port "80"
should be listening
Finished in 0.19273 seconds (files took 0.64301 seconds
to load)
4 examples, 0 failures
テスト成功時(一部抜粋)
43. 42
Service "httpd"
should be enabled
should be running (FAILED - 1)
Failures:
1) Service "httpd" should be running
On host `companyA.advanspey.com'
Failure/Error: it { should be_running }
expected Service "httpd" to be running
/bin/sh -c service¥ httpd¥ status
httpd is stopped
# ./spec/companyA.advanspey.com/sample_spec.rb:14
Finished in 0.19489 seconds (files took 0.64632 seconds to load)
4 examples, 2 failures
テスト失敗時(一部抜粋)