diff options
-rw-r--r-- | lib/puppet/parser/functions/concat.rb | 6 | ||||
-rwxr-xr-x | spec/functions/concat_spec.rb | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb index 6c86382..0d35b07 100644 --- a/lib/puppet/parser/functions/concat.rb +++ b/lib/puppet/parser/functions/concat.rb @@ -28,11 +28,7 @@ Would result in: raise(Puppet::ParseError, 'concat(): Requires array to work with') end - if b.is_a?(Array) - result = a.concat(b) - else - result = a << b - end + result = a + Array(b) return result end diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index b853b4c..49cb2ad 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -27,4 +27,9 @@ describe "the concat function" do expect(result).to(eq(['1','2','3',['4','5'],'6'])) end + it "should leave the original array intact" do + array_original = ['1','2','3'] + result = scope.function_concat([array_original,['4','5','6']]) + array_original.should(eq(['1','2','3'])) + end end |