From b53ea1b90c8e050b1ce3008995ebfcb0ca0baf62 Mon Sep 17 00:00:00 2001 From: Daniele Sluijters Date: Fri, 27 Feb 2015 12:07:56 +0100 Subject: [PATCH] spec/(apt|ppa): Enough with all the strings. Most options can and should be named through symbols, makes it much easier to read too with syntax highlighting. --- spec/classes/apt_spec.rb | 82 ++++++++++++++++++++-------------------- spec/defines/ppa_spec.rb | 56 +++++++++++++-------------- 2 files changed, 69 insertions(+), 69 deletions(-) diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b8ff37e..b07e0d6 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -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 diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 6ca008b..dde015a 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -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 -- 2.45.2