summaryrefslogtreecommitdiff
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
parentc7c8647634df07f0de0e662360eb4567f7c20770 (diff)
downloadpuppet-stdlib-1abf4b62fc8e97c7096c9da3d350e3e6268c5c72.tar.gz
puppet-stdlib-1abf4b62fc8e97c7096c9da3d350e3e6268c5c72.tar.bz2
Few more tests.
-rw-r--r--lib/puppet/parser/functions/date.rb2
-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
6 files changed, 31 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/date.rb b/lib/puppet/parser/functions/date.rb
index bc62e60..0439bd1 100644
--- a/lib/puppet/parser/functions/date.rb
+++ b/lib/puppet/parser/functions/date.rb
@@ -8,7 +8,7 @@ module Puppet::Parser::Functions
) do |arguments|
if (arguments.size != 1) then
- raise(Puppet::ParseError, "is_valid_netmask(): Wrong number of arguments "+
+ raise(Puppet::ParseError, "date(): Wrong number of arguments "+
"given #{arguments.size} for 1")
end
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