]> gitweb.fluxo.info Git - puppet-tftp.git/commitdiff
Single it block per test
authorcrayfishx <craig@craigdunn.org>
Wed, 11 Jul 2012 17:30:36 +0000 (10:30 -0700)
committercrayfishx <craig@craigdunn.org>
Wed, 11 Jul 2012 17:30:36 +0000 (10:30 -0700)
* as originally submitted in https://github.com/puppetlabs/puppetlabs-tftp/pull/10...
* Only use one it block per test to improve performance

spec/classes/tftp_spec.rb
spec/defines/tftp_file_spec.rb

index 055f1b59ab7b78ff179007248aed35a3ce2c89cf..21e6f727cc06a287dd111bdf9d29c0a03f49224e 100644 (file)
@@ -6,14 +6,16 @@ describe 'tftp', :type => :class do
                     :osfamily         => 'Debian',
                     :path             => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should contain_file('/etc/default/tftpd-hpa') }
-    it { should contain_package('tftpd-hpa') }
-    it { should contain_service('tftpd-hpa').with({
-      'ensure'    => 'running',
-      'enable'    => true,
-      'hasstatus' => false,
-      'provider'  => nil,
-    }) }
+    it {
+      should contain_file('/etc/default/tftpd-hpa')
+      should contain_package('tftpd-hpa')
+      should contain_service('tftpd-hpa').with({
+       'ensure'    => 'running',
+       'enable'    => true,
+       'hasstatus' => false,
+       'provider'  => nil,
+      })
+    }
   end
 
   describe 'when deploying on ubuntu' do
@@ -21,31 +23,35 @@ describe 'tftp', :type => :class do
                     :osfamily         => 'Debian',
                     :path             => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should contain_package('tftpd-hpa') }
-    it { should contain_file('/etc/default/tftpd-hpa') }
-    it { should contain_service('tftpd-hpa').with({
-      'ensure'    => 'running',
-      'enable'    => true,
-      'hasstatus' => true,
-      'provider'  => 'upstart',
-    }) }
+    it {
+      should contain_package('tftpd-hpa')
+      should contain_file('/etc/default/tftpd-hpa')
+      should contain_service('tftpd-hpa').with({
+        'ensure'    => 'running',
+       'enable'    => true,
+       'hasstatus' => true,
+       'provider'  => 'upstart',
+      })
+    }
   end
 
   describe 'when deploying on redhat family' do
     let (:facts) { {  :osfamily         => 'RedHat',
                       :path             => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should contain_package('tftpd-hpa').with({
-      'name'      => 'tftp-server',
-    }) }
-
-    it { should contain_service('tftpd-hpa').with({
-      'ensure'    => 'running',
-      'enable'    => 'true',
-      'hasstatus' => false,
-      'provider'  => 'base',
-      'start'     => '/usr/sbin/in.tftpd -l -a 0.0.0.0:69 -u nobody --secure /var/lib/tftpboot',
-    }) }
+    it {
+      should contain_package('tftpd-hpa').with({
+        'name'      => 'tftp-server',
+    })
+
+      should contain_service('tftpd-hpa').with({
+       'ensure'    => 'running',
+       'enable'    => 'true',
+       'hasstatus' => false,
+       'provider'  => 'base',
+       'start'     => '/usr/sbin/in.tftpd -l -a 0.0.0.0:69 -u nobody --secure /var/lib/tftpboot',
+      })
+    }
   end
 
   describe 'when deploying on redhat family with custom options' do
@@ -57,41 +63,44 @@ describe 'tftp', :type => :class do
                       :options          => '--secure --timeout 50',
                       :directory        => '/tftpboot', } }
 
-    it { should contain_package('tftpd-hpa').with({
-      'name'      => 'tftp-server',
-    }) }
-
-    it { should contain_service('tftpd-hpa').with({
-      'ensure'    => 'running',
-      'enable'    => 'true',
-      'hasstatus' => false,
-      'provider'  => 'base',
-      'start'     => '/usr/sbin/in.tftpd -l -a 127.0.0.1:1069 -u root --secure --timeout 50 /tftpboot',
-    }) }
+    it {
+      should contain_package('tftpd-hpa').with({
+        'name'      => 'tftp-server',
+      })
+
+      should contain_service('tftpd-hpa').with({
+        'ensure'    => 'running',
+        'enable'    => 'true',
+        'hasstatus' => false,
+        'provider'  => 'base',
+        'start'     => '/usr/sbin/in.tftpd -l -a 127.0.0.1:1069 -u root --secure --timeout 50 /tftpboot',
+      })
+    }
   end
 
   describe 'when deploying with xinetd on redhat family' do
     let (:facts) { {  :osfamily => 'Redhat',
                       :path     => '/usr/local/bin:/usr/bin:/bin', } }
     let (:params) { { :inetd    => true, } }
-    it { should include_class('xinetd') }
-    it { should contain_service('tftpd-hpa').with({
-      'ensure'      => 'stopped',
-      'enable'      => false,
-    }) }
-    it { should contain_xinetd__service('tftp').with({
-      'port'        => '69',
-      'protocol'    => 'udp',
-      'server_args' => '--secure /var/lib/tftpboot',
-      'server'      => '/usr/sbin/in.tftpd',
-      'user'        => 'nobody',
-      'socket_type' => 'dgram',
-      'cps'         => '100 2',
-      'flags'       => 'IPv4',
-      'per_source'   => '11',
-      'wait'        => 'yes',
-   }) }
-
+    it {
+      should include_class('xinetd')
+      should contain_service('tftpd-hpa').with({
+        'ensure'      => 'stopped',
+        'enable'      => false,
+    })
+      should contain_xinetd__service('tftp').with({
+        'port'        => '69',
+        'protocol'    => 'udp',
+        'server_args' => '--secure /var/lib/tftpboot',
+        'server'      => '/usr/sbin/in.tftpd',
+        'user'        => 'nobody',
+        'socket_type' => 'dgram',
+        'cps'         => '100 2',
+        'flags'       => 'IPv4',
+        'per_source'   => '11',
+        'wait'        => 'yes',
+      })
+    }
   end
 
   describe 'when deploying with xinetd on ubuntu' do
@@ -99,24 +108,25 @@ describe 'tftp', :type => :class do
                       :operatingsystem  => 'Ubuntu',
                       :path     => '/usr/local/bin:/usr/bin:/bin', } }
     let (:params) { { :inetd    => true, } }
-    it { should include_class('xinetd') }
-    it { should contain_service('tftpd-hpa').with({
-      'ensure'      => 'stopped',
-      'enable'      => false,
-    }) }
-    it { should contain_xinetd__service('tftp').with({
-      'port'        => '69',
-      'protocol'    => 'udp',
-      'server_args' => '--secure /var/lib/tftpboot',
-      'server'      => '/usr/sbin/in.tftpd',
-      'user'        => 'tftp',
-      'socket_type' => 'dgram',
-      'cps'         => '100 2',
-      'flags'       => 'IPv4',
-      'per_source'   => '11',
-      'wait'        => 'yes',
-   }) }
-
+    it {
+      should include_class('xinetd')
+      should contain_service('tftpd-hpa').with({
+        'ensure'      => 'stopped',
+        'enable'      => false,
+      })
+      should contain_xinetd__service('tftp').with({
+        'port'        => '69',
+        'protocol'    => 'udp',
+        'server_args' => '--secure /var/lib/tftpboot',
+        'server'      => '/usr/sbin/in.tftpd',
+        'user'        => 'tftp',
+        'socket_type' => 'dgram',
+        'cps'         => '100 2',
+        'flags'       => 'IPv4',
+        'per_source'   => '11',
+        'wait'        => 'yes',
+      })
+    }
   end
 
   describe 'when deploying with xinetd on debian' do
@@ -124,21 +134,22 @@ describe 'tftp', :type => :class do
                       :operatingsystem  => 'Debian',
                       :path     => '/usr/local/bin:/usr/bin:/bin', } }
     let (:params) { { :inetd    => true, } }
-    it { should include_class('xinetd') }
-    it { should contain_xinetd__service('tftp').with({
-      'port'        => '69',
-      'protocol'    => 'udp',
-      'server_args' => '--secure /srv/tftp',
-      'server'      => '/usr/sbin/in.tftpd',
-      'user'        => 'tftp',
-      'socket_type' => 'dgram',
-      'cps'         => '100 2',
-      'flags'       => 'IPv4',
-      'per_source'  => '11',
-      'wait'        => 'yes',
-      'bind'        => '0.0.0.0',
-   }) }
-
+    it {
+      should include_class('xinetd')
+      should contain_xinetd__service('tftp').with({
+        'port'        => '69',
+        'protocol'    => 'udp',
+        'server_args' => '--secure /srv/tftp',
+        'server'      => '/usr/sbin/in.tftpd',
+        'user'        => 'tftp',
+        'socket_type' => 'dgram',
+        'cps'         => '100 2',
+        'flags'       => 'IPv4',
+        'per_source'  => '11',
+        'wait'        => 'yes',
+        'bind'        => '0.0.0.0',
+      })
+    }
   end
 
   describe 'when deploying with xinetd with custom options' do
@@ -147,21 +158,22 @@ describe 'tftp', :type => :class do
                       :path     => '/usr/local/bin:/usr/bin:/bin', } }
     let (:params) { { :inetd    => true,
                       :options  => '--secure --timeout 50', } }
-    it { should include_class('xinetd') }
-    it { should contain_xinetd__service('tftp').with({
-      'port'        => '69',
-      'protocol'    => 'udp',
-      'server_args' => '--secure --timeout 50 /srv/tftp',
-      'server'      => '/usr/sbin/in.tftpd',
-      'user'        => 'tftp',
-      'socket_type' => 'dgram',
-      'cps'         => '100 2',
-      'flags'       => 'IPv4',
-      'per_source'  => '11',
-      'wait'        => 'yes',
-      'bind'        => '0.0.0.0',
-   }) }
-
+    it {
+      should include_class('xinetd')
+      should contain_xinetd__service('tftp').with({
+        'port'        => '69',
+        'protocol'    => 'udp',
+        'server_args' => '--secure --timeout 50 /srv/tftp',
+        'server'      => '/usr/sbin/in.tftpd',
+        'user'        => 'tftp',
+        'socket_type' => 'dgram',
+        'cps'         => '100 2',
+        'flags'       => 'IPv4',
+        'per_source'  => '11',
+        'wait'        => 'yes',
+        'bind'        => '0.0.0.0',
+      })
+    }
   end
 
   describe 'when deploying with xinetd with custom settings' do
@@ -173,21 +185,22 @@ describe 'tftp', :type => :class do
                       :address    => '127.0.0.1',
                       :username   => 'root',
                       :directory  => '/tftpboot', } }
-    it { should include_class('xinetd') }
-    it { should contain_xinetd__service('tftp').with({
-      'port'        => '1069',
-      'protocol'    => 'udp',
-      'server_args' => '--secure /tftpboot',
-      'server'      => '/usr/sbin/in.tftpd',
-      'user'        => 'root',
-      'socket_type' => 'dgram',
-      'cps'         => '100 2',
-      'flags'       => 'IPv4',
-      'per_source'   => '11',
-      'wait'        => 'yes',
-      'bind'        => '127.0.0.1',
-   }) }
-
+    it {
+      should include_class('xinetd')
+      should contain_xinetd__service('tftp').with({
+        'port'        => '1069',
+        'protocol'    => 'udp',
+        'server_args' => '--secure /tftpboot',
+        'server'      => '/usr/sbin/in.tftpd',
+        'user'        => 'root',
+        'socket_type' => 'dgram',
+        'cps'         => '100 2',
+        'flags'       => 'IPv4',
+        'per_source'   => '11',
+        'wait'        => 'yes',
+        'bind'        => '127.0.0.1',
+      })
+    }
   end
 
 end
index 84c9e3383d7725d711e4e78d673733500d8e7fc9..1ad62d8dfad1415cd80db2324ba026d4182ccaab 100644 (file)
@@ -9,14 +9,16 @@ describe 'tftp::file' do
                     :osfamily        => 'Debian',
                     :path            => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure'  => 'file',
-      'owner'   => 'tftp',
-      'group'   => 'tftp',
-      'mode'    => '0644',
-      'recurse' => false,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure'  => 'file',
+        'owner'   => 'tftp',
+        'group'   => 'tftp',
+        'mode'    => '0644',
+        'recurse' => false,
+      })
+    }
   end
 
   describe 'when deploying on ubuntu' do
@@ -24,14 +26,16 @@ describe 'tftp::file' do
                     :osfamily        => 'Debian',
                     :path            => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/var/lib/tftpboot/sample').with({
-      'ensure'  => 'file',
-      'owner'   => 'tftp',
-      'group'   => 'tftp',
-      'mode'    => '0644',
-      'recurse' => false,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/var/lib/tftpboot/sample').with({
+        'ensure'  => 'file',
+        'owner'   => 'tftp',
+        'group'   => 'tftp',
+        'mode'    => '0644',
+        'recurse' => false,
+      })
+    }
   end
 
   describe 'when deploying with parameters' do
@@ -44,14 +48,16 @@ describe 'tftp::file' do
                     :osfamily        => 'Debian',
                     :path            => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure'  => 'directory',
-      'owner'   => 'root',
-      'group'   => 'root',
-      'mode'    => '0755',
-      'recurse' => true,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure'  => 'directory',
+        'owner'   => 'root',
+        'group'   => 'root',
+        'mode'    => '0755',
+        'recurse' => true,
+      })
+    }
   end
 
   describe 'when deploying without recurse parameters' do
@@ -59,14 +65,16 @@ describe 'tftp::file' do
                    :osfamily        => 'Debian',
                    :path            => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure'       => 'file',
-      'recurse'      => false,
-      'purge'        => nil,
-      'replace'      => nil,
-      'recurselimit' => nil,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure'       => 'file',
+        'recurse'      => false,
+        'purge'        => nil,
+        'replace'      => nil,
+        'recurselimit' => nil,
+      })
+    }
   end
 
   describe 'when deploying with recurse parameters' do
@@ -80,17 +88,19 @@ describe 'tftp::file' do
                    :osfamily        => 'Debian',
                    :path            => '/usr/local/bin:/usr/bin:/bin', }}
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure'       => 'directory',
-      'owner'        => 'tftp',
-      'group'        => 'tftp',
-      'mode'         => '0755',
-      'recurse'      => true,
-      'recurselimit' => 42,
-      'purge'        => true,
-      'replace'      => false,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure'       => 'directory',
+        'owner'        => 'tftp',
+        'group'        => 'tftp',
+        'mode'         => '0755',
+        'recurse'      => true,
+        'recurselimit' => 42,
+        'purge'        => true,
+        'replace'      => false,
+      })
+    }
   end
 
   describe 'when deploying directory' do
@@ -101,12 +111,14 @@ describe 'tftp::file' do
                     :caller_module_name => 'acme',
                     :path               => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure' => 'directory',
-      'mode'   => '0755',
-      'source' => nil,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure' => 'directory',
+        'mode'   => '0755',
+        'source' => nil,
+      })
+    }
   end
 
   describe 'when deploying file from another module' do
@@ -117,12 +129,14 @@ describe 'tftp::file' do
                     :caller_module_name => 'acme',
                     :path               => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure' => 'file',
-      'mode'   => '0755',
-      'source' => 'puppet:///modules/acme/sample'
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure' => 'file',
+        'mode'   => '0755',
+        'source' => 'puppet:///modules/acme/sample'
+      })
+    }
   end
 
   describe 'when deploying file with content' do
@@ -134,12 +148,15 @@ describe 'tftp::file' do
                     :caller_module_name => 'acme',
                     :path               => '/usr/local/bin:/usr/bin:/bin', } }
 
-    it { should include_class('tftp') }
-    it { should contain_file('/srv/tftp/sample').with({
-      'ensure'  => 'file',
-      'mode'    => '0755',
-      'content' => 'hi',
-      'source'  => nil,
-    }) }
+    it {
+      should include_class('tftp')
+      should contain_file('/srv/tftp/sample').with({
+        'ensure'  => 'file',
+        'mode'    => '0755',
+        'content' => 'hi',
+        'source'  => nil,
+      })
+    }
   end
+
 end