summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/parser/functions/concat.rb2
-rwxr-xr-xspec/acceptance/concat_spec.rb14
-rwxr-xr-xspec/functions/concat_spec.rb1
3 files changed, 16 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb
index 618e62d..91edb4e 100644
--- a/lib/puppet/parser/functions/concat.rb
+++ b/lib/puppet/parser/functions/concat.rb
@@ -31,7 +31,7 @@ Would result in:
arguments.shift
arguments.each do |x|
- result = result + Array(x)
+ result = result + (x.is_a?(Array) ? x : [x])
end
return result
diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb
index 06b649f..c472db6 100755
--- a/spec/acceptance/concat_spec.rb
+++ b/spec/acceptance/concat_spec.rb
@@ -36,5 +36,19 @@ describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper
apply_manifest(pp, :catch_failures => true)
end
+ it 'should concat hash arguments' do
+ pp = <<-EOS
+ $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
+ validate_array($output)
+ if size($output) != 2 {
+ fail("${output} should have 2 elements.")
+ }
+ if $output[1] != {"c" => "d", "e" => "f"} {
+ fail("${output} does not have the expected hash for the second element.")
+ }
+ EOS
+
+ apply_manifest(pp, :catch_failures => true)
+ end
end
end
diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb
index 1694d5e..eb76233 100755
--- a/spec/functions/concat_spec.rb
+++ b/spec/functions/concat_spec.rb
@@ -11,6 +11,7 @@ describe 'concat' do
it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) }
it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) }
it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) }
+ it { is_expected.to run.with_params([{"a" => "b"}], {"c" => "d", "e" => "f"}).and_return([{"a" => "b"}, {"c" => "d", "e" => "f"}]) }
it "should leave the original array intact" do
argument1 = ['1','2','3']