diff options
author | Mickaël Canévet <mickael.canevet@camptocamp.com> | 2014-12-26 11:26:03 +0100 |
---|---|---|
committer | Mickaël Canévet <mickael.canevet@camptocamp.com> | 2014-12-26 11:26:03 +0100 |
commit | be0781a9237fecd07f97a3651437136dcaa34ee7 (patch) | |
tree | d9bb695b5bddf22aaa1abbf07c356867a5a89dfb /spec/defines/dhcp_shared_network_spec.rb | |
parent | 372f3340c5ee7143c95a399a3b0d4cc07dfba3e0 (diff) | |
download | puppet-dhcp-be0781a9237fecd07f97a3651437136dcaa34ee7.tar.gz puppet-dhcp-be0781a9237fecd07f97a3651437136dcaa34ee7.tar.bz2 |
Use rspec-puppet-facts
Diffstat (limited to 'spec/defines/dhcp_shared_network_spec.rb')
-rw-r--r-- | spec/defines/dhcp_shared_network_spec.rb | 135 |
1 files changed, 69 insertions, 66 deletions
diff --git a/spec/defines/dhcp_shared_network_spec.rb b/spec/defines/dhcp_shared_network_spec.rb index aa22d9e..5fda39e 100644 --- a/spec/defines/dhcp_shared_network_spec.rb +++ b/spec/defines/dhcp_shared_network_spec.rb @@ -2,82 +2,85 @@ require 'spec_helper' describe 'dhcp::shared_network' do let (:title) { 'My network' } - let (:facts) { { - :operatingsystem => 'Debian', - :osfamily => 'Debian', - :lsbdistcodename => 'squeeze', - :id => 'root', - :path => '/foo/bar' - } } - context 'when passing wrong value for ensure' do - let (:params) { { - :ensure => 'running', - } } + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ + :concat_basedir => '/var/lib/puppet/concat', + }) + end - it 'should fail' do - expect { - should contain_concat__fragment('dhcp-shared-My network') - }.to raise_error(Puppet::Error, /\$ensure must be either 'present' or 'absent', got 'running'/) - end - end + context 'when passing wrong value for ensure' do + let (:params) { { + :ensure => 'running', + } } - context 'when passing wrong type for subnets' do - let (:params) { { - :subnets => true, - } } + it 'should fail' do + expect { + should contain_concat__fragment('dhcp-shared-My network') + }.to raise_error(Puppet::Error, /\$ensure must be either 'present' or 'absent', got 'running'/) + end + end - it 'should fail' do - expect { - should contain_concat__fragment('dhcp-shared-My network') - }.to raise_error(Puppet::Error, /true is not an Array\./) - end - end + context 'when passing wrong type for subnets' do + let (:params) { { + :subnets => true, + } } - context 'when passing no parameters' do - it { should contain_concat__fragment('dhcp-shared-My network').with( - :ensure => 'present', - :target => '/etc/dhcp/dhcpd.conf' - ).with_content( - /shared-network My network \{\n\}/ - ) - } - end + it 'should fail' do + expect { + should contain_concat__fragment('dhcp-shared-My network') + }.to raise_error(Puppet::Error, /true is not an Array\./) + end + end - context 'when passing wrong type for a subnet' do - let (:params) { { - :subnets => [true], - } } + context 'when passing no parameters' do + it { should contain_concat__fragment('dhcp-shared-My network').with( + :ensure => 'present', + :target => '/etc/dhcp/dhcpd.conf' + ).with_content( + /shared-network My network \{\n\}/ + ) + } + end - it 'should fail' do - expect { - should contain_concat__fragment('dhcp-shared-My network') - }.to raise_error(Puppet::Error, /true is not a string\./) - end - end + context 'when passing wrong type for a subnet' do + let (:params) { { + :subnets => [true], + } } - context 'when passing wrong value for a subnet' do - let (:params) { { - :subnets => ['wrong value'], - } } + it 'should fail' do + expect { + should contain_concat__fragment('dhcp-shared-My network') + }.to raise_error(Puppet::Error, /true is not a string\./) + end + end - it 'should fail' do - expect { - should contain_concat__fragment('dhcp-shared-My network') - }.to raise_error(Puppet::Error, /"wrong value" does not match/) - end - end + context 'when passing wrong value for a subnet' do + let (:params) { { + :subnets => ['wrong value'], + } } - context 'when passing subnets' do - let (:params) { { - :subnets => ['1.2.3.4', '5.6.7.8'], - } } + it 'should fail' do + expect { + should contain_concat__fragment('dhcp-shared-My network') + }.to raise_error(Puppet::Error, /"wrong value" does not match/) + end + end - it { should contain_concat__fragment('dhcp-shared-My network').with( - :ensure => 'present', - :target => '/etc/dhcp/dhcpd.conf' - ).with_content( - /shared-network My network \{\n include "\/etc\/dhcp\/subnets\/1\.2\.3\.4\.conf";\n include "\/etc\/dhcp\/subnets\/5\.6\.7\.8\.conf";\n\}/) - } + context 'when passing subnets' do + let (:params) { { + :subnets => ['1.2.3.4', '5.6.7.8'], + } } + + it { should contain_concat__fragment('dhcp-shared-My network').with( + :ensure => 'present', + :target => '/etc/dhcp/dhcpd.conf' + ).with_content( + /shared-network My network \{\n include "\/etc\/dhcp\/subnets\/1\.2\.3\.4\.conf";\n include "\/etc\/dhcp\/subnets\/5\.6\.7\.8\.conf";\n\}/) + } + end + end end end |