diff options
author | Raphaël Pinson <raphael.pinson@camptocamp.com> | 2013-04-14 23:50:03 -0700 |
---|---|---|
committer | Raphaël Pinson <raphael.pinson@camptocamp.com> | 2013-04-14 23:50:03 -0700 |
commit | 93895f1f039956ec9d02df511aaeaed885ae34bf (patch) | |
tree | 704909c98dc11bb9206b2c67f3f8557418507a21 /spec/defines/dhcp_shared_network_spec.rb | |
parent | 87162a8cc3e47996160f85e1807f75b9ad741bc8 (diff) | |
parent | c0f46562b70777b9a4a39429d94c49e869150c64 (diff) | |
download | puppet-dhcp-93895f1f039956ec9d02df511aaeaed885ae34bf.tar.gz puppet-dhcp-93895f1f039956ec9d02df511aaeaed885ae34bf.tar.bz2 |
Merge pull request #5 from raphink/dev/cleanup
Cleanup, refactor…
Diffstat (limited to 'spec/defines/dhcp_shared_network_spec.rb')
-rw-r--r-- | spec/defines/dhcp_shared_network_spec.rb | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/spec/defines/dhcp_shared_network_spec.rb b/spec/defines/dhcp_shared_network_spec.rb new file mode 100644 index 0000000..d59f73c --- /dev/null +++ b/spec/defines/dhcp_shared_network_spec.rb @@ -0,0 +1,81 @@ +require 'spec_helper' + +describe 'dhcp::shared_network' do + let (:title) { 'My network' } + let (:facts) { { + :operatingsystem => 'Debian', + :osfamily => 'Debian', + :lsbdistcodename => 'squeeze' + } } + + context 'when passing wrong value for ensure' do + let (:params) { { + :ensure => 'running', + } } + + 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 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, /true is not an Array\./) + end + end + + 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 + + context 'when passing wrong type for a subnet' do + let (:params) { { + :subnets => [true], + } } + + 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 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, /"wrong value" does not match/) + end + end + + 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 |