summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/functions/ensure_packages.rb2
-rwxr-xr-xspec/functions/ensure_packages_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb
index 532b702..439af1e 100644
--- a/lib/puppet/parser/functions/ensure_packages.rb
+++ b/lib/puppet/parser/functions/ensure_packages.rb
@@ -25,7 +25,7 @@ third argument to the ensure_resource() function.
end
Puppet::Parser::Functions.function(:ensure_resources)
- function_ensure_resources(['package', Hash(arguments[0]), defaults ])
+ function_ensure_resources(['package', arguments[0].dup, defaults ])
else
packages = Array(arguments[0])
diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb
index c824732..5d97684 100755
--- a/spec/functions/ensure_packages_spec.rb
+++ b/spec/functions/ensure_packages_spec.rb
@@ -33,4 +33,12 @@ describe 'ensure_packages' do
it { expect(lambda { catalogue }).to contain_package('facter').with_ensure('present').with_provider("gem") }
end
end
+
+ context 'given hash of packages' do
+ before { subject.call([{"foo" => { "provider" => "rpm" }, "bar" => { "provider" => "gem" }}, { "ensure" => "present"}]) }
+
+ # this lambda is required due to strangeness within rspec-puppet's expectation handling
+ it { expect(lambda { catalogue }).to contain_package('foo').with({'provider' => 'rpm', 'ensure' => 'present'}) }
+ it { expect(lambda { catalogue }).to contain_package('bar').with({'provider' => 'gem', 'ensure' => 'present'}) }
+ end
end