]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Allow a single argument, rather than an array
authorTomas Doran <tdoran@yelp.com>
Tue, 19 Nov 2013 18:38:12 +0000 (18:38 +0000)
committerAdrien Thebo <git@somethingsinistral.net>
Wed, 15 Jan 2014 19:03:33 +0000 (11:03 -0800)
lib/puppet/parser/functions/ensure_packages.rb
spec/functions/ensure_packages_spec.rb

index 450ea026d1a6013231ed54082a2880598bccc420..371d63a19944b74cb0798da36ff5a6ca117d50f1 100644 (file)
@@ -11,8 +11,7 @@ Takes a list of packages and only installs them if they don't already exist.
 
     raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " +
       "given (#{arguments.size} for 1)") if arguments.size != 1
-    raise(Puppet::ParseError, "ensure_packages(): Requires array " +
-      "given (#{arguments[0].class})") if !arguments[0].kind_of?(Array)
+    arguments[0] = [ arguments[0] ] unless arguments[0].kind_of?(Array)
 
     Puppet::Parser::Functions.function(:ensure_resource)
     arguments[0].each { |package_name|
index 6fd56d5c135e9bff00c5093f149a9a342e06714c..f6272af0e7548c4f0a947d9758d296276b56c397 100644 (file)
@@ -13,8 +13,9 @@ describe 'ensure_packages' do
     it 'requires an array' do
       lambda { scope.function_ensure_packages([['foo']]) }.should_not raise_error
     end
-    it 'fails when given a string' do
-      should run.with_params('foo').and_raise_error(Puppet::ParseError)
+
+    it 'accepts a single package name as a string' do
+      scope.function_ensure_packages(['foo'])
     end
   end