diff modules/apache/spec/classes/mod/status_spec.rb @ 36:37675581a273 puppet-3.6

Update Puppet module for Apache (pulls in concat module)
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2015 20:07:04 +0000
parents 956e484adc12
children 675c1cc61eaf
line wrap: on
line diff
--- a/modules/apache/spec/classes/mod/status_spec.rb	Sat Mar 14 20:01:17 2015 +0000
+++ b/modules/apache/spec/classes/mod/status_spec.rb	Sat Mar 14 20:07:04 2015 +0000
@@ -1,10 +1,10 @@
 require 'spec_helper'
 
 # Helper function for testing the contents of `status.conf`
-def status_conf_spec(allow_from, extended_status)
+def status_conf_spec(allow_from, extended_status, status_path)
   it do
-    should contain_file("status.conf").with_content(
-      "<Location /server-status>\n"\
+    is_expected.to contain_file("status.conf").with_content(
+      "<Location #{status_path}>\n"\
       "    SetHandler server-status\n"\
       "    Order deny,allow\n"\
       "    Deny from all\n"\
@@ -31,19 +31,25 @@
         :osfamily               => 'Debian',
         :operatingsystemrelease => '6',
         :concat_basedir         => '/dne',
+        :lsbdistcodename        => 'squeeze',
+        :operatingsystem        => 'Debian',
+        :id                     => 'root',
+        :kernel                 => 'Linux',
+        :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+        :is_pe                  => false,
       }
     end
 
-    it { should contain_apache__mod("status") }
+    it { is_expected.to contain_apache__mod("status") }
 
-    status_conf_spec(["127.0.0.1", "::1"], "On")
+    status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
 
-    it { should contain_file("status.conf").with({
+    it { is_expected.to contain_file("status.conf").with({
       :ensure => 'file',
       :path   => '/etc/apache2/mods-available/status.conf',
     } ) }
 
-    it { should contain_file("status.conf symlink").with({
+    it { is_expected.to contain_file("status.conf symlink").with({
       :ensure => 'link',
       :path   => '/etc/apache2/mods-enabled/status.conf',
     } ) }
@@ -56,33 +62,45 @@
         :osfamily               => 'RedHat',
         :operatingsystemrelease => '6',
         :concat_basedir         => '/dne',
+        :operatingsystem        => 'RedHat',
+        :id                     => 'root',
+        :kernel                 => 'Linux',
+        :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+        :is_pe                  => false,
       }
     end
 
-    it { should contain_apache__mod("status") }
+    it { is_expected.to contain_apache__mod("status") }
 
-    status_conf_spec(["127.0.0.1", "::1"], "On")
+    status_conf_spec(["127.0.0.1", "::1"], "On", "/server-status")
 
-    it { should contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") }
+    it { is_expected.to contain_file("status.conf").with_path("/etc/httpd/conf.d/status.conf") }
 
   end
 
-  context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off'" do
+  context "with custom parameters $allow_from => ['10.10.10.10','11.11.11.11'], $extended_status => 'Off', $status_path => '/custom-status'" do
     let :facts do
       {
         :osfamily               => 'Debian',
         :operatingsystemrelease => '6',
         :concat_basedir         => '/dne',
+        :lsbdistcodename        => 'squeeze',
+        :operatingsystem        => 'Debian',
+        :id                     => 'root',
+        :kernel                 => 'Linux',
+        :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+        :is_pe                  => false,
       }
     end
     let :params do
       {
         :allow_from => ['10.10.10.10','11.11.11.11'],
         :extended_status => 'Off',
+        :status_path => '/custom-status',
       }
     end
 
-    status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off")
+    status_conf_spec(["10.10.10.10", "11.11.11.11"], "Off", "/custom-status")
 
   end
 
@@ -92,6 +110,12 @@
         :osfamily               => 'Debian',
         :operatingsystemrelease => '6',
         :concat_basedir         => '/dne',
+        :lsbdistcodename        => 'squeeze',
+        :operatingsystem        => 'Debian',
+        :id                     => 'root',
+        :kernel                 => 'Linux',
+        :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+        :is_pe                  => false,
       }
     end
     let :params do
@@ -99,7 +123,7 @@
     end
     it 'should expect to succeed array validation' do
       expect {
-        should contain_file("status.conf")
+        is_expected.to contain_file("status.conf")
       }.not_to raise_error()
     end
   end
@@ -110,6 +134,11 @@
         :osfamily               => 'Debian',
         :operatingsystemrelease => '6',
         :concat_basedir         => '/dne',
+        :operatingsystem        => 'Debian',
+        :id                     => 'root',
+        :kernel                 => 'Linux',
+        :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+        :is_pe                  => false,
       }
     end
     let :params do
@@ -117,7 +146,7 @@
     end
     it 'should expect to fail array validation' do
       expect {
-        should contain_file("status.conf")
+        is_expected.to contain_file("status.conf")
       }.to raise_error(Puppet::Error)
     end
   end
@@ -130,6 +159,12 @@
           :osfamily               => 'Debian',
           :operatingsystemrelease => '6',
           :concat_basedir         => '/dne',
+          :lsbdistcodename        => 'squeeze',
+          :operatingsystem        => 'Debian',
+          :id                     => 'root',
+          :kernel                 => 'Linux',
+          :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+          :is_pe                  => false,
         }
       end
       let :params do
@@ -137,7 +172,7 @@
       end
       it 'should expect to succeed regular expression validation' do
         expect {
-          should contain_file("status.conf")
+          is_expected.to contain_file("status.conf")
         }.not_to raise_error()
       end
     end
@@ -150,6 +185,11 @@
           :osfamily               => 'Debian',
           :operatingsystemrelease => '6',
           :concat_basedir         => '/dne',
+          :operatingsystem        => 'Debian',
+          :id                     => 'root',
+          :kernel                 => 'Linux',
+          :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+          :is_pe                  => false,
         }
       end
       let :params do
@@ -157,7 +197,7 @@
       end
       it 'should expect to fail regular expression validation' do
         expect {
-          should contain_file("status.conf")
+          is_expected.to contain_file("status.conf")
         }.to raise_error(Puppet::Error)
       end
     end