]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Few more tests.
authorKen Barber <ken@bob.sh>
Wed, 29 Jun 2011 23:00:32 +0000 (01:00 +0200)
committerKen Barber <ken@bob.sh>
Wed, 29 Jun 2011 23:00:32 +0000 (01:00 +0200)
lib/puppet/parser/functions/date.rb
spec/unit/parser/functions/bool2num_spec.rb
spec/unit/parser/functions/capitalize_spec.rb
spec/unit/parser/functions/chomp_spec.rb
spec/unit/parser/functions/chop_spec.rb
spec/unit/parser/functions/count_spec.rb

index bc62e60c503cee79899a0a738a4bb4e0d6a37031..0439bd1f0494faa12d12797978fbb11e44b614fa 100644 (file)
@@ -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
 
index a2585e96ef3f5267c63cf81059b901c52d1bdb76..d5da18c8d60d0701280974c2906a047299a89d5e 100755 (executable)
@@ -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
index bb1fe2a41aae702d03c8c9dbea06e02309d7c1b7..1c45821ae64b288db78f3c65bcde2d2385c65f42 100755 (executable)
@@ -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
index 150a7c8547085b52df3bbf403895935ca001c394..0592115054d8f1ecdedc41f993757e7d0dc40dba 100755 (executable)
@@ -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
index ae636cbf57431e3f23792d8f86079c91f2061342..0c456a8af2a3d6afdc9a8e50d624a9f73faf144e 100755 (executable)
@@ -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
index 28617c9537eaf3740c08fd68d2679e5b51c446e6..62d005a5098adede98a02f984c602ccce1b8a752 100755 (executable)
@@ -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