diff options
author | Michael Moll <kvedulv@kvedulv.de> | 2012-10-19 20:14:46 +0200 |
---|---|---|
committer | Michael Moll <kvedulv@kvedulv.de> | 2012-12-10 20:43:34 +0100 |
commit | 63cc300fb2ff662ae5fbd2268001032c0cabba8c (patch) | |
tree | 8b51569d9f977cbf99e90b0d32985d77bb9b9d2c /spec | |
parent | 66ef82f35c83a1e156f5e6d97158e80177dd4ae1 (diff) |
update unit tests for osfamily fact
Diffstat (limited to 'spec')
-rw-r--r-- | spec/classes/ntp_spec.rb | 98 |
1 files changed, 44 insertions, 54 deletions
diff --git a/spec/classes/ntp_spec.rb b/spec/classes/ntp_spec.rb index 389f085..239f641 100644 --- a/spec/classes/ntp_spec.rb +++ b/spec/classes/ntp_spec.rb @@ -11,80 +11,70 @@ describe 'ntp' do describe 'test platform specific resources' do - debianish = ['debian', 'ubuntu'] - redhatish = ['centos', 'redhat', 'oel', 'linux'] - bsdish = ['freebsd'] - - debianish.each do |os| - describe "for operating system #{os}" do - - let(:params) {{}} - let(:facts) { { :operatingsystem => os } } - - it { should contain_service('ntp').with_name('ntp') } - it 'should use the debian ntp servers by default' do - content = param_value(subject, 'file', '/etc/ntp.conf', 'content') - expected_lines = ['server 0.debian.pool.ntp.org iburst', - 'server 1.debian.pool.ntp.org iburst', - 'server 2.debian.pool.ntp.org iburst', - 'server 3.debian.pool.ntp.org iburst'] - (content.split("\n") & expected_lines).should == expected_lines - end + describe "for operating system family Debian" do + + let(:params) {{}} + let(:facts) { { :osfamily => 'debian' } } + + it { should contain_service('ntp').with_name('ntp') } + it 'should use the debian ntp servers by default' do + content = param_value(subject, 'file', '/etc/ntp.conf', 'content') + expected_lines = ['server 0.debian.pool.ntp.org iburst', + 'server 1.debian.pool.ntp.org iburst', + 'server 2.debian.pool.ntp.org iburst', + 'server 3.debian.pool.ntp.org iburst'] + (content.split("\n") & expected_lines).should == expected_lines end end - redhatish.each do |os| - describe "for operating system #{os}" do + describe "for operating system family RedHat" do - let(:params) {{}} - let(:facts) { { :operatingsystem => os } } + let(:params) {{}} + let(:facts) { { :osfamily => 'redhat' } } - it { should contain_service('ntp').with_name('ntpd') } - it 'should use the redhat ntp servers by default' do - content = param_value(subject, 'file', '/etc/ntp.conf', 'content') - expected_lines = [ - 'server 0.centos.pool.ntp.org', - 'server 1.centos.pool.ntp.org', - 'server 2.centos.pool.ntp.org'] - (content.split("\n") & expected_lines).should == expected_lines - end + it { should contain_service('ntp').with_name('ntpd') } + it 'should use the redhat ntp servers by default' do + content = param_value(subject, 'file', '/etc/ntp.conf', 'content') + expected_lines = [ + 'server 0.centos.pool.ntp.org', + 'server 1.centos.pool.ntp.org', + 'server 2.centos.pool.ntp.org'] + (content.split("\n") & expected_lines).should == expected_lines end end - bsdish.each do |os| - describe "for operating system #{os}" do - - let(:params) {{}} - let(:facts) { { :operatingsystem => os } } - - it { should contain_service('ntp').with_name('ntpd') } - it 'should use the freebsd ntp servers by default' do - content = param_value(subject, 'file', '/etc/ntp.conf', 'content') - expected_lines = [ - "server 0.freebsd.pool.ntp.org iburst maxpoll 9", - "server 1.freebsd.pool.ntp.org iburst maxpoll 9", - "server 2.freebsd.pool.ntp.org iburst maxpoll 9", - "server 3.freebsd.pool.ntp.org iburst maxpoll 9"] - (content.split("\n") & expected_lines).should == expected_lines - end + describe "for operating system family FreeBSD" do + + let(:params) {{}} + let(:facts) { { :osfamily => 'freebsd' } } + + it { should contain_service('ntp').with_name('ntpd') } + it 'should use the freebsd ntp servers by default' do + content = param_value(subject, 'file', '/etc/ntp.conf', 'content') + expected_lines = [ + "server 0.freebsd.pool.ntp.org iburst maxpoll 9", + "server 1.freebsd.pool.ntp.org iburst maxpoll 9", + "server 2.freebsd.pool.ntp.org iburst maxpoll 9", + "server 3.freebsd.pool.ntp.org iburst maxpoll 9"] + (content.split("\n") & expected_lines).should == expected_lines end - describe "for operating system unsupported" do + describe "for operating system family unsupported" do let(:facts) {{ - :operatingsystem => 'unsupported', + :osfamily => 'unsupported', }} it { expect{ subject }.to raise_error( - /^The ntp module is not supported on unsupported/ + /^The ntp module is not supported on unsupported based systems/ )} end end - (redhatish + debianish + bsdish).each do |os| - describe "for operating system #{os}" do + ['Debian', 'RedHat', 'FreeBSD'].each do |osfamily| + describe "for operating system family #{osfamily}" do - let(:facts) { { :operatingsystem => os } } + let(:facts) { { :osfamily => osfamily } } it { should contain_file('/etc/ntp.conf').with_owner('0') } it { should contain_file('/etc/ntp.conf').with_group('0') } |