From ed192a04648db7786d072bef23ed72849115d9de Mon Sep 17 00:00:00 2001 From: Peter Souter <p.souter@kainos.com> Date: Thu, 4 Dec 2014 14:12:55 +0000 Subject: (MODULES-444) Add specs for new behaviour `concat` can now take multiple arguments --- spec/functions/concat_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'spec/functions/concat_spec.rb') diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index 49cb2ad..4a18cd9 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -32,4 +32,14 @@ describe "the concat function" do result = scope.function_concat([array_original,['4','5','6']]) array_original.should(eq(['1','2','3'])) end + + it "should be able to concat multiple arrays" do + result = scope.function_concat([['1','2','3'],['4','5','6'],['7','8','9']]) + expect(result).to(eq(['1','2','3','4','5','6','7','8','9'])) + end + + it "should be able to concat mix of primitives and arrays to a final array" do + result = scope.function_concat([['1','2','3'],'4',['5','6','7']]) + expect(result).to(eq(['1','2','3','4','5','6','7'])) + end end -- cgit v1.2.3 From 7a1c4a6d9e4123a59fa85be18bd1b86ed5539b56 Mon Sep 17 00:00:00 2001 From: Peter Souter <p.souter@kainos.com> Date: Thu, 4 Dec 2014 14:27:38 +0000 Subject: (MODULES-444) Change test to > 2 arguments Also add extra test for just 1 argument --- spec/functions/concat_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec/functions/concat_spec.rb') diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index 4a18cd9..d443c4b 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -4,8 +4,9 @@ require 'spec_helper' describe "the concat function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - it "should raise a ParseError if the client does not provide two arguments" do + it "should raise a ParseError if the client does not provide at least two arguments" do expect { scope.function_concat([]) }.to(raise_error(Puppet::ParseError)) + expect { scope.function_concat([[1]]) }.to(raise_error(Puppet::ParseError)) end it "should raise a ParseError if the first parameter is not an array" do -- cgit v1.2.3 From 368c97f08046696d453afca6e1f8001b5bfc88a5 Mon Sep 17 00:00:00 2001 From: Peter Souter <p.souter@kainos.com> Date: Thu, 4 Dec 2014 14:27:55 +0000 Subject: (MODULES-444) - Check for accepting > 2 args --- spec/functions/concat_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'spec/functions/concat_spec.rb') diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index d443c4b..49fa6bb 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -13,6 +13,10 @@ describe "the concat function" do expect { scope.function_concat([1, []])}.to(raise_error(Puppet::ParseError)) end + it "should not raise a ParseError if the client provides more than two arguments" do + expect { scope.function_concat([[1],[2],[3]]) }.not_to raise_error + end + it "should be able to concat an array" do result = scope.function_concat([['1','2','3'],['4','5','6']]) expect(result).to(eq(['1','2','3','4','5','6'])) -- cgit v1.2.3