Skip to content

Commit 842992e

Browse files
authored
Merge pull request #1196 from cocker-cc/Fix_ensure_packages
Fix ensure_packages
2 parents ba0345e + 77a9c07 commit 842992e

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lib/puppet/parser/functions/ensure_packages.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ module Puppet::Parser::Functions
2020

2121
if arguments[0].is_a?(Hash)
2222
if arguments[1]
23-
defaults = { 'ensure' => 'present' }.merge(arguments[1])
24-
if defaults['ensure'] == 'installed'
25-
defaults['ensure'] = 'present'
23+
defaults = { 'ensure' => 'installed' }.merge(arguments[1])
24+
if defaults['ensure'] == 'present'
25+
defaults['ensure'] = 'installed'
2626
end
2727
else
28-
defaults = { 'ensure' => 'present' }
28+
defaults = { 'ensure' => 'installed' }
2929
end
3030

3131
Puppet::Parser::Functions.function(:ensure_resources)
@@ -34,12 +34,12 @@ module Puppet::Parser::Functions
3434
packages = Array(arguments[0])
3535

3636
if arguments[1]
37-
defaults = { 'ensure' => 'present' }.merge(arguments[1])
38-
if defaults['ensure'] == 'installed'
39-
defaults['ensure'] = 'present'
37+
defaults = { 'ensure' => 'installed' }.merge(arguments[1])
38+
if defaults['ensure'] == 'present'
39+
defaults['ensure'] = 'installed'
4040
end
4141
else
42-
defaults = { 'ensure' => 'present' }
42+
defaults = { 'ensure' => 'installed' }
4343
end
4444

4545
Puppet::Parser::Functions.function(:ensure_resource)

spec/functions/ensure_packages_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525
# this lambda is required due to strangeness within rspec-puppet's expectation handling
2626
it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent') }
27-
it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present') }
27+
it { expect(-> { catalogue }).to contain_package('facter').with_ensure('installed') }
2828
end
2929

3030
describe 'after running ensure_package("facter", { "provider" => "gem" })' do
3131
before(:each) { subject.execute('facter', 'provider' => 'gem') }
3232

3333
# this lambda is required due to strangeness within rspec-puppet's expectation handling
3434
it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('absent').without_provider }
35-
it { expect(-> { catalogue }).to contain_package('facter').with_ensure('present').with_provider('gem') }
35+
it { expect(-> { catalogue }).to contain_package('facter').with_ensure('installed').with_provider('gem') }
3636
end
3737
end
3838

@@ -52,23 +52,23 @@
5252
end
5353

5454
# this lambda is required due to strangeness within rspec-puppet's expectation handling
55-
it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'present') }
56-
it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'present') }
55+
it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'installed') }
56+
it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'installed') }
5757

5858
context 'with UTF8 and double byte characters' do
5959
it { expect(-> { catalogue }).to contain_package('パッケージ').with('ensure' => 'absent') }
6060
it { expect(-> { catalogue }).to contain_package('ρǻ¢κầģẻ').with('ensure' => 'absent') }
6161
end
6262
end
6363

64-
context 'when given a catalog with "package { puppet: ensure => present }"' do
65-
let(:pre_condition) { 'package { puppet: ensure => present }' }
64+
context 'when given a catalog with "package { puppet: ensure => installed }"' do
65+
let(:pre_condition) { 'package { puppet: ensure => installed }' }
6666

67-
describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do
68-
before(:each) { subject.execute('puppet', 'ensure' => 'installed') }
67+
describe 'after running ensure_package("puppet", { "ensure" => "present" })' do
68+
before(:each) { subject.execute('puppet', 'ensure' => 'present') }
6969

7070
# this lambda is required due to strangeness within rspec-puppet's expectation handling
71-
it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('present') }
71+
it { expect(-> { catalogue }).to contain_package('puppet').with_ensure('installed') }
7272
end
7373
end
7474
end

0 commit comments

Comments
 (0)