From 1abf4b62fc8e97c7096c9da3d350e3e6268c5c72 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Thu, 30 Jun 2011 01:00:32 +0200 Subject: Few more tests. --- spec/unit/parser/functions/bool2num_spec.rb | 10 ++++++++++ spec/unit/parser/functions/capitalize_spec.rb | 5 +++++ spec/unit/parser/functions/chomp_spec.rb | 5 +++++ spec/unit/parser/functions/chop_spec.rb | 5 +++++ spec/unit/parser/functions/count_spec.rb | 5 +++++ 5 files changed, 30 insertions(+) (limited to 'spec/unit/parser') diff --git a/spec/unit/parser/functions/bool2num_spec.rb b/spec/unit/parser/functions/bool2num_spec.rb index a2585e9..d5da18c 100755 --- a/spec/unit/parser/functions/bool2num_spec.rb +++ b/spec/unit/parser/functions/bool2num_spec.rb @@ -18,4 +18,14 @@ describe "the bool2num function" do lambda { @scope.function_bool2num([]) }.should( raise_error(Puppet::ParseError)) end + it "should convert true to 1" do + result = @scope.function_bool2num([true]) + result.should(eq(1)) + end + + it "should convert false to 0" do + result = @scope.function_bool2num([false]) + result.should(eq(0)) + end + end diff --git a/spec/unit/parser/functions/capitalize_spec.rb b/spec/unit/parser/functions/capitalize_spec.rb index bb1fe2a..1c45821 100755 --- a/spec/unit/parser/functions/capitalize_spec.rb +++ b/spec/unit/parser/functions/capitalize_spec.rb @@ -18,4 +18,9 @@ describe "the capitalize function" do lambda { @scope.function_capitalize([]) }.should( raise_error(Puppet::ParseError)) end + it "should capitalize the beginning of a string" do + result = @scope.function_capitalize(["abc"]) + result.should(eq("Abc")) + end + end diff --git a/spec/unit/parser/functions/chomp_spec.rb b/spec/unit/parser/functions/chomp_spec.rb index 150a7c8..0592115 100755 --- a/spec/unit/parser/functions/chomp_spec.rb +++ b/spec/unit/parser/functions/chomp_spec.rb @@ -18,4 +18,9 @@ describe "the chomp function" do lambda { @scope.function_chomp([]) }.should( raise_error(Puppet::ParseError)) end + it "should chomp the end of a string" do + result = @scope.function_chomp(["abc\n"]) + result.should(eq("abc")) + end + end diff --git a/spec/unit/parser/functions/chop_spec.rb b/spec/unit/parser/functions/chop_spec.rb index ae636cb..0c456a8 100755 --- a/spec/unit/parser/functions/chop_spec.rb +++ b/spec/unit/parser/functions/chop_spec.rb @@ -18,4 +18,9 @@ describe "the chop function" do lambda { @scope.function_chop([]) }.should( raise_error(Puppet::ParseError)) end + it "should chop the end of a string" do + result = @scope.function_chop(["asdf\n"]) + result.should(eq("asdf")) + end + end diff --git a/spec/unit/parser/functions/count_spec.rb b/spec/unit/parser/functions/count_spec.rb index 28617c9..62d005a 100755 --- a/spec/unit/parser/functions/count_spec.rb +++ b/spec/unit/parser/functions/count_spec.rb @@ -18,4 +18,9 @@ describe "the count function" do lambda { @scope.function_count([]) }.should( raise_error(Puppet::ParseError)) end + it "should return the size of an array" do + result = @scope.function_count([['a','c','b']]) + result.should(eq(3)) + end + end -- cgit v1.2.3