aboutsummaryrefslogtreecommitdiff
path: root/spec/defines/dhcp_shared_network_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/defines/dhcp_shared_network_spec.rb')
-rw-r--r--spec/defines/dhcp_shared_network_spec.rb135
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