aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-11 12:34:23 +0200
committerRaphaël Pinson <raphael.pinson@camptocamp.com>2013-04-11 12:34:23 +0200
commit4cc54cff2d04eedb672c7cc6b92a5edcccac63c9 (patch)
treee57fe01acc4bc319cdcba4b245649687874527e3 /spec
parent87096a875d4bee517e0c8c807218394a2024bd46 (diff)
downloadpuppet-dhcp-4cc54cff2d04eedb672c7cc6b92a5edcccac63c9.tar.gz
puppet-dhcp-4cc54cff2d04eedb672c7cc6b92a5edcccac63c9.tar.bz2
Add spec tests for the dhcp class
Diffstat (limited to 'spec')
-rw-r--r--spec/classes/dhcp_spec.rb73
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/classes/dhcp_spec.rb b/spec/classes/dhcp_spec.rb
new file mode 100644
index 0000000..c833c52
--- /dev/null
+++ b/spec/classes/dhcp_spec.rb
@@ -0,0 +1,73 @@
+require 'spec_helper'
+
+describe 'dhcp' do
+ context 'When on an unsupported OS' do
+ let (:facts) { {
+ :operatingsystem => 'RedHat',
+ :osfamily => 'Redhat',
+ :lsbdistcodename => 'Santiago'
+ } }
+
+ it 'should fail' do
+ expect {
+ should contain_package('dhcp-server')
+ }.to raise_error(Puppet::Error, /Unsupported OS RedHat\/Santiago/)
+ end
+ end
+
+ context 'When on Debian lenny' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'lenny'
+ } }
+
+ # Package
+ it { should contain_package('dhcp-server').with(
+ :name => 'dhcp3-server'
+ ) }
+
+ # Config
+ it { should contain_concat('/etc/dhcp3/dhcpd.conf').with(
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644'
+ ) }
+
+ # Service
+ it { should contain_service('dhcpd').with(
+ :ensure => 'running',
+ :name => 'dhcp3-server',
+ :enable => true,
+ :pattern => '/usr/sbin/dhcpd3'
+ ) }
+ end
+
+ context 'When on Debian squeeze' do
+ let (:facts) { {
+ :operatingsystem => 'Debian',
+ :osfamily => 'Debian',
+ :lsbdistcodename => 'squeeze'
+ } }
+
+ # Package
+ it { should contain_package('dhcp-server').with(
+ :name => 'isc-dhcp-server'
+ ) }
+
+ # Config
+ it { should contain_concat('/etc/dhcp/dhcpd.conf').with(
+ :owner => 'root',
+ :group => 'root',
+ :mode => '0644'
+ ) }
+
+ # Service
+ it { should contain_service('dhcpd').with(
+ :ensure => 'running',
+ :name => 'isc-dhcp-server',
+ :enable => true,
+ :pattern => '/usr/sbin/dhcpd'
+ ) }
+ end
+end