summaryrefslogtreecommitdiff
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-06-30 01:00:32 +0200
committerKen Barber <ken@bob.sh>2011-06-30 01:00:32 +0200
commit1abf4b62fc8e97c7096c9da3d350e3e6268c5c72 (patch)
tree75d5ab5335884b5f0571f3995fe6af763f9c5f0e /spec/unit/parser
parentc7c8647634df07f0de0e662360eb4567f7c20770 (diff)
Few more tests.
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/functions/bool2num_spec.rb10
-rwxr-xr-xspec/unit/parser/functions/capitalize_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/chomp_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/chop_spec.rb5
-rwxr-xr-xspec/unit/parser/functions/count_spec.rb5
5 files changed, 30 insertions, 0 deletions
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