diff modules/apache/spec/defines/balancer_spec.rb @ 275:d9352a684e62

Mass update of modules to remove deprecation warnings
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Jan 2020 11:36:07 +0000
parents 675c1cc61eaf
children
line wrap: on
line diff
--- a/modules/apache/spec/defines/balancer_spec.rb	Sat Jan 04 11:42:45 2020 +0000
+++ b/modules/apache/spec/defines/balancer_spec.rb	Sun Jan 26 11:36:07 2020 +0000
@@ -1,56 +1,66 @@
 require 'spec_helper'
 
-describe 'apache::balancer', :type => :define do
+describe 'apache::balancer', type: :define do
   let :title do
     'myapp'
   end
   let :facts do
     {
-      :osfamily               => 'Debian',
-      :operatingsystem        => 'Debian',
-      :operatingsystemrelease => '6',
-      :lsbdistcodename        => 'squeeze',
-      :id                     => 'root',
-      :concat_basedir         => '/dne',
-      :path                   => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
-      :kernel                 => 'Linux',
-      :is_pe                  => false,
+      osfamily: 'Debian',
+      operatingsystem: 'Debian',
+      operatingsystemrelease: '8',
+      lsbdistcodename: 'jessie',
+      id: 'root',
+      path: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
+      kernel: 'Linux',
+      is_pe: false,
     }
   end
+
   describe 'apache pre_condition with defaults' do
     let :pre_condition do
       'include apache'
     end
-    describe "accept a target parameter and use it" do
+
+    describe 'works when only declaring resource title' do
+      it { is_expected.to contain_concat('apache_balancer_myapp') }
+      it { is_expected.to contain_concat__fragment('00-myapp-header').with_content(%r{^<Proxy balancer://myapp>$}) }
+    end
+    describe 'accept a target parameter and use it' do
       let :params do
         {
-          :target => '/tmp/myapp.conf'
+          target: '/tmp/myapp.conf',
         }
       end
-      it { should contain_concat('apache_balancer_myapp').with({
-        :path => "/tmp/myapp.conf",
-      })}
-      it { should_not contain_apache__mod('slotmem_shm') }
-      it { should_not contain_apache__mod('lbmethod_byrequests') }
+
+      it {
+        is_expected.to contain_concat('apache_balancer_myapp').with(path: '/tmp/myapp.conf')
+      }
     end
-    context "on jessie" do
-      let(:facts) { super().merge({
-        :operatingsystemrelease => '8',
-        :lsbdistcodename        => 'jessie',
-      }) }
-      it { should contain_apache__mod('slotmem_shm') }
-      it { should contain_apache__mod('lbmethod_byrequests') }
+    describe 'accept an options parameter and use it' do
+      let :params do
+        {
+          options: ['timeout=0', 'nonce=none'],
+        }
+      end
+
+      it {
+        is_expected.to contain_concat__fragment('00-myapp-header').with_content(
+          %r{^<Proxy balancer://myapp timeout=0 nonce=none>$},
+        )
+      }
     end
   end
-  describe 'apache pre_condition with conf_dir set' do 
+  describe 'apache pre_condition with conf_dir set' do
     let :pre_condition do
       'class{"apache":
           confd_dir => "/junk/path"
        }'
     end
-    it { should contain_concat('apache_balancer_myapp').with({
-      :path => "/junk/path/balancer_myapp.conf",
-    })}
+
+    it {
+      is_expected.to contain_concat('apache_balancer_myapp').with(path: '/junk/path/balancer_myapp.conf')
+    }
   end
 
   describe 'with lbmethod and with apache::mod::proxy_balancer::apache_version set' do
@@ -61,12 +71,13 @@
     end
     let :params do
       {
-        :proxy_set => {
+        proxy_set: {
           'lbmethod' => 'bytraffic',
         },
       }
     end
-    it { should contain_apache__mod('slotmem_shm') }
-    it { should contain_apache__mod('lbmethod_bytraffic') }
+
+    it { is_expected.to contain_apache__mod('slotmem_shm') }
+    it { is_expected.to contain_apache__mod('lbmethod_bytraffic') }
   end
 end