Skip to content

Commit 164e55a

Browse files
authored
Merge pull request #930 from jbro/any2array
Make any2array return empty array on empty string
2 parents 822c4d2 + 2febc34 commit 164e55a

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

lib/puppet/parser/functions/any2array.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module Puppet::Parser::Functions
3232

3333
return arguments unless arguments.length == 1
3434
return arguments[0] if arguments[0].is_a?(Array)
35+
return [] if arguments == ['']
3536
if arguments[0].is_a?(Hash)
3637
result = []
3738
arguments[0].each do |key, value|

spec/functions/any2array_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
describe 'any2array' do
44
it { is_expected.not_to eq(nil) }
55
it { is_expected.to run.with_params.and_return([]) }
6+
it { is_expected.to run.with_params('').and_return([]) }
67
it { is_expected.to run.with_params(true).and_return([true]) }
78
it { is_expected.to run.with_params('one').and_return(['one']) }
89
it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) }

0 commit comments

Comments
 (0)