diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index 3cd2b2014..ef0cccaaf 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -20,12 +20,12 @@ module Puppet::Parser::Functions if arguments[0].is_a?(Hash) if arguments[1] - defaults = { 'ensure' => 'present' }.merge(arguments[1]) - if defaults['ensure'] == 'installed' - defaults['ensure'] = 'present' + defaults = { 'ensure' => 'installed' }.merge(arguments[1]) + if defaults['ensure'] == 'present' + defaults['ensure'] = 'installed' end else - defaults = { 'ensure' => 'present' } + defaults = { 'ensure' => 'installed' } end Puppet::Parser::Functions.function(:ensure_resources) @@ -34,12 +34,12 @@ module Puppet::Parser::Functions packages = Array(arguments[0]) if arguments[1] - defaults = { 'ensure' => 'present' }.merge(arguments[1]) - if defaults['ensure'] == 'installed' - defaults['ensure'] = 'present' + defaults = { 'ensure' => 'installed' }.merge(arguments[1]) + if defaults['ensure'] == 'present' + defaults['ensure'] = 'installed' end else - defaults = { 'ensure' => 'present' } + defaults = { 'ensure' => 'installed' } end Puppet::Parser::Functions.function(:ensure_resource) diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 1f6b85db0..41a8846af 100644 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -24,7 +24,7 @@ # this lambda is required due to strangeness within rspec-puppet's expectation handling it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent') } - it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present') } + it { expect(-> { catalogue }).to contain_package('facter').with_ensure('installed') } end describe 'after running ensure_package("facter", { "provider" => "gem" })' do @@ -32,7 +32,7 @@ # this lambda is required due to strangeness within rspec-puppet's expectation handling it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider } - it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present').with_provider('gem') } + it { expect(-> { catalogue }).to contain_package('facter').with_ensure('installed').with_provider('gem') } end end @@ -52,8 +52,8 @@ end # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'present') } - it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'present') } + it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'installed') } + it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'installed') } context 'with UTF8 and double byte characters' do it { expect(-> { catalogue }).to contain_package('パッケージ').with('ensure' => 'absent') } @@ -61,14 +61,14 @@ end end - context 'when given a catalog with "package { puppet: ensure => present }"' do - let(:pre_condition) { 'package { puppet: ensure => present }' } + context 'when given a catalog with "package { puppet: ensure => installed }"' do + let(:pre_condition) { 'package { puppet: ensure => installed }' } - describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do - before(:each) { subject.execute('puppet', 'ensure' => 'installed') } + describe 'after running ensure_package("puppet", { "ensure" => "present" })' do + before(:each) { subject.execute('puppet', 'ensure' => 'present') } # this lambda is required due to strangeness within rspec-puppet's expectation handling - it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') } + it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('installed') } end end end