What is the best way to write tests that react differently depending on the platform they are running on?
My use case is the following:
I want to ensure my system is protected against the heartbleed bug in open ssl. This means verifying that the chef installed openssl packages are up to date. For CentOS the last vulnerable version is 1.0.1e-15 while for Ubuntu it is 1.0.1-4ubuntu5.11
This would be dependent on which test runner you are using, but for Serverspec:
describe command('openssl --version'), :if => os[:family] == 'ubuntu' do
its(:stdout) { is_expected.to include '1.0.1-4ubuntu5.11' }
end
(untested, but note the use of the os[:family]
helper)