]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
spec/(apt|ppa): Enough with all the strings.
authorDaniele Sluijters <daenney@users.noreply.github.com>
Fri, 27 Feb 2015 11:07:56 +0000 (12:07 +0100)
committerDaniele Sluijters <daenney@users.noreply.github.com>
Fri, 27 Feb 2015 11:20:41 +0000 (12:20 +0100)
Most options can and should be named through symbols, makes it much
easier to read too with syntax highlighting.

spec/classes/apt_spec.rb
spec/defines/ppa_spec.rb

index b8ff37ea312caee1153a9c574c73b2520c9b4723..b07e0d6a769e11d8b7b1c1da5ecc7900fef8f38a 100644 (file)
@@ -1,46 +1,46 @@
 require 'spec_helper'
-describe 'apt', :type => :class do
+describe 'apt' do
   let(:facts) { { :lsbdistid => 'Debian', :osfamily => 'Debian' } }
 
   context 'defaults' do
     it { is_expected.to contain_file('sources.list').that_notifies('Exec[apt_update]').only_with({
-      'ensure' => 'present',
-      'path'   => '/etc/apt/sources.list',
-      'owner'  => 'root',
-      'group'  => 'root',
-      'mode'   => '0644',
-      'notify' => 'Exec[apt_update]',
+      :ensure => 'present',
+      :path   => '/etc/apt/sources.list',
+      :owner  => 'root',
+      :group  => 'root',
+      :mode   => '0644',
+      :notify => 'Exec[apt_update]',
     })}
 
     it { is_expected.to contain_file('sources.list.d').that_notifies('Exec[apt_update]').only_with({
-      'ensure'  => 'directory',
-      'path'    => '/etc/apt/sources.list.d',
-      'owner'   => 'root',
-      'group'   => 'root',
-      'purge'   => false,
-      'recurse' => false,
-      'notify'  => 'Exec[apt_update]',
+      :ensure  => 'directory',
+      :path    => '/etc/apt/sources.list.d',
+      :owner   => 'root',
+      :group   => 'root',
+      :purge   => false,
+      :recurse => false,
+      :notify  => 'Exec[apt_update]',
     })}
 
     it { is_expected.to contain_file('preferences.d').only_with({
-      'ensure'  => 'directory',
-      'path'    => '/etc/apt/preferences.d',
-      'owner'   => 'root',
-      'group'   => 'root',
-      'purge'   => false,
-      'recurse' => false,
+      :ensure  => 'directory',
+      :path    => '/etc/apt/preferences.d',
+      :owner   => 'root',
+      :group   => 'root',
+      :purge   => false,
+      :recurse => false,
     })}
 
     it 'should lay down /etc/apt/apt.conf.d/15update-stamp' do
       is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with({
-        'group' => 'root',
-        'mode'  => '0644',
-        'owner' => 'root',
+        :group => 'root',
+        :mode  => '0644',
+        :owner => 'root',
       }).with_content(/APT::Update::Post-Invoke-Success \{"touch \/var\/lib\/apt\/periodic\/update-success-stamp 2>\/dev\/null \|\| true";\};/)
     end
 
     it { is_expected.to contain_exec('apt_update').with({
-      'refreshonly' => 'true',
+      :refreshonly => 'true',
     })}
   end
 
@@ -58,28 +58,28 @@ describe 'apt', :type => :class do
     end
 
     it { is_expected.to contain_file('sources.list').with({
-      'content' => "# Repos managed by puppet.\n"
+      :content => "# Repos managed by puppet.\n"
     })}
 
     it { is_expected.to contain_file('sources.list.d').with({
-      'purge'   => 'true',
-      'recurse' => 'true',
+      :purge   => 'true',
+      :recurse => 'true',
     })}
 
     it { is_expected.to contain_file('apt-preferences').only_with({
-      'ensure' => 'absent',
-      'path'   => '/etc/apt/preferences',
+      :ensure => 'absent',
+      :path   => '/etc/apt/preferences',
     })}
 
     it { is_expected.to contain_file('preferences.d').with({
-      'purge'   => 'true',
-      'recurse' => 'true',
+      :purge   => 'true',
+      :recurse => 'true',
     })}
 
     it { is_expected.to contain_exec('apt_update').with({
-      'refreshonly' => 'false',
-      'timeout'     => '1',
-      'tries'       => '3',
+      :refreshonly => 'false',
+      :timeout     => '1',
+      :tries       => '3',
     })}
 
   end
@@ -99,7 +99,7 @@ describe 'apt', :type => :class do
         'key'               => '55BE302B',
         'key_server'        => 'subkeys.pgp.net',
         'pin'               => '-10',
-        'include_src'       => true
+        'include_src'       => true,
       },
       'puppetlabs' => {
         'location'   => 'http://apt.puppetlabs.com',
@@ -111,7 +111,7 @@ describe 'apt', :type => :class do
 
     it {
       is_expected.to contain_apt__setting('list-debian_unstable').with({
-        'ensure'  => 'present',
+        :ensure => 'present',
       })
     }
 
@@ -120,7 +120,7 @@ describe 'apt', :type => :class do
 
     it {
       is_expected.to contain_apt__setting('list-puppetlabs').with({
-        'ensure'  => 'present',
+        :ensure => 'present',
       })
     }
 
@@ -131,7 +131,7 @@ describe 'apt', :type => :class do
     context 'bad purge_sources_list' do
       let :params do
         {
-          'purge_sources_list' => 'foo'
+          :purge_sources_list => 'foo'
         }
       end
       it do
@@ -144,7 +144,7 @@ describe 'apt', :type => :class do
     context 'bad purge_sources_list_d' do
       let :params do
         {
-          'purge_sources_list_d' => 'foo'
+          :purge_sources_list_d => 'foo'
         }
       end
       it do
@@ -157,7 +157,7 @@ describe 'apt', :type => :class do
     context 'bad purge_preferences' do
       let :params do
         {
-          'purge_preferences' => 'foo'
+          :purge_preferences => 'foo'
         }
       end
       it do
@@ -170,7 +170,7 @@ describe 'apt', :type => :class do
     context 'bad purge_preferences_d' do
       let :params do
         {
-          'purge_preferences_d' => 'foo'
+          :purge_preferences_d => 'foo'
         }
       end
       it do
index 6ca008b4ba8399919d8b368568c90259c46322d2..dde015abad483c8de23c1e3b3605c8904edcaa9e 100644 (file)
@@ -1,5 +1,5 @@
 require 'spec_helper'
-describe 'apt::ppa', :type => :define do
+describe 'apt::ppa' do
 
   describe 'defaults' do
     let :pre_condition do
@@ -18,11 +18,11 @@ describe 'apt::ppa', :type => :define do
     let(:title) { 'ppa:needs/such.substitution/wow' }
     it { is_expected.to_not contain_package('python-software-properties') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Exec[apt_update]').with({
-      'environment' => [],
-      'command'     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => [],
+      :command     => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
   end
@@ -42,18 +42,18 @@ describe 'apt::ppa', :type => :define do
     end
     let :params do
       {
-        'options' => '',
-        'package_manage' => true,
+        :options => '',
+        :package_manage => true,
       }
     end
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
-      'environment' => [],
-      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => [],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
   end
@@ -81,11 +81,11 @@ describe 'apt::ppa', :type => :define do
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
-      'environment' => ['http_proxy=http://localhost:8080', 'https_proxy=http://localhost:8080'],
-      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => ['http_proxy=http://localhost:8080', 'https_proxy=http://localhost:8080'],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
   end
@@ -105,19 +105,19 @@ describe 'apt::ppa', :type => :define do
     end
     let :params do
       {
-        'options' => '',
-        'package_manage' => true,
-        'proxy' => { 'host' => 'localhost', 'port' => 8180, }
+        :options => '',
+        :package_manage => true,
+        :proxy => { 'host' => 'localhost', 'port' => 8180, }
       }
     end
     let(:title) { 'ppa:foo' }
     it { is_expected.to contain_package('software-properties-common') }
     it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
-      'environment' => ['http_proxy=http://localhost:8180', 'https_proxy=http://localhost:8180'],
-      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
-      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
-      'user'        => 'root',
-      'logoutput'   => 'on_failure',
+      :environment => ['http_proxy=http://localhost:8180', 'https_proxy=http://localhost:8180'],
+      :command     => '/usr/bin/add-apt-repository  ppa:foo',
+      :unless      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      :user        => 'root',
+      :logoutput   => 'on_failure',
     })
     }
   end
@@ -138,11 +138,11 @@ describe 'apt::ppa', :type => :define do
     let(:title) { 'ppa:foo' }
     let :params do
       {
-        'ensure' => 'absent'
+        :ensure => 'absent'
       }
     end
     it { is_expected.to contain_file('/etc/apt/sources.list.d/foo-trusty.list').that_notifies('Exec[apt_update]').with({
-      'ensure' => 'absent',
+      :ensure => 'absent',
     })
     }
   end