前回に続き、今回はテストコードを実際に記述していきます。
まずは、ディレクトリが存在するかのテストコードです。
下記コードは、/var/www/htmlがディレクトリとして存在するかをテストします
describe file('/var/www/html') do
it { should be_directory }
end
シンボリックリンクが正しいか
/var/www/redmineのリンク先が、/opt/redmine であるかをテストします。
describe file('/var/www/redmine') do
it { should be_linked_to '/opt/redmine' }
end
SELINUXがdisabledであるかをテストします。
shared_examples_for 'support selinux be_disabled matcher' do
describe selinux do
it { should be_disabled }
end
end
/etc/ld.so.confファイルが存在するか、またその中身に
/usr/local/libの記載があるか
/etc という記載がないか
をテストします。
describe file('/etc/ld.so.conf') do
it { should be_file }
it { should contain '/usr/local/lib' }
it { should_not contain '/etc' }
end
httpdパッケージがインストールされているかをテストします。
describe package('httpd') do
it { should be_installed }
end
/usr/local/bin/php -m | grep imagick コマンドを実行し、標準出力の内容にimagickがあるかをテストします。
describe command('/usr/local/bin/php -m|grep imagick') do
it { should return_stdout 'imagick' }
end
httpdが実行されているか、自動起動が有効化をテストします。
describe service('httpd') do
it { should be_enabled }
it { should be_running }
end
その他は、公式HPにて確認してみてください。