end
it "should convert a negative number into a positive" do
- result = @scope.function_abs([-34])
+ result = @scope.function_abs(["-34"])
result.should(eq(34))
end
+ it "should do nothing with a positive number" do
+ result = @scope.function_abs(["5678"])
+ result.should(eq(5678))
+ end
+
end
result.should(eq("asfd"))
end
+ it "should do nothing to a string that is already downcase" do
+ result = @scope.function_downcase(["asdf asdf"])
+ result.should(eq("asdf asdf"))
+ end
+
end
result.should(eq(true))
end
+ it "should return a false for a non-empty string" do
+ result = @scope.function_empty(['asdf'])
+ result.should(eq(false))
+ end
+
end
result.should(eq(["a","b","c","d","e","f","g"]))
end
+ it "should do nothing to a structure that is already flat" do
+ result = @scope.function_flatten([["a","b","c","d"]])
+ result.should(eq(["a","b","c","d"]))
+ end
+
end
result.should(eq(false))
end
+ it "should return false if passed a string" do
+ result = @scope.function_is_array(["asdf"])
+ result.should(eq(false))
+ end
+
end
result.should(eq(false))
end
- it "should return false if not an integer" do
+ it "should return false if an integer" do
result = @scope.function_is_float(["3"])
result.should(eq(false))
end
it "should return true if 1" do
result = @scope.function_num2bool(["1"])
- result.should(eq(true))
+ result.should(be_true)
+ end
+
+ it "should return false if 0" do
+ result = @scope.function_num2bool(["0"])
+ result.should(be_false)
end
end
lambda { @scope.function_shuffle([]) }.should( raise_error(Puppet::ParseError))
end
+ it "should shuffle a string and the result should be the same size" do
+ result = @scope.function_shuffle(["asdf"])
+ result.size.should(eq(4))
+ end
+
+ it "should shuffle a string but the sorted contents should still be the same" do
+ result = @scope.function_shuffle(["adfs"])
+ result.split("").sort.to_s.should(eq("adfs"))
+ end
+
end
lambda { @scope.function_strftime([]) }.should( raise_error(Puppet::ParseError))
end
+ it "using %s should be higher then when I wrote this test" do
+ result = @scope.function_strftime(["%s"])
+ result.to_i.should(be > 1311953157)
+ end
+
+ it "using %s should be lower then 1.5 trillion" do
+ result = @scope.function_strftime(["%s"])
+ result.to_i.should(be < 1500000000)
+ end
+
+ it "should return a date when given %Y-%m-%d" do
+ result = @scope.function_strftime(["%Y-%m-%d"])
+ result.should =~ /^\d{4}-\d{2}-\d{2}$/
+ end
+
end
lambda { @scope.function_time(['','']) }.should( raise_error(Puppet::ParseError))
end
+ it "should return a number" do
+ result = @scope.function_time([])
+ result.class.should(eq(Fixnum))
+ end
+
+ it "should be higher then when I wrote this test" do
+ result = @scope.function_time([])
+ result.should(be > 1311953157)
+ end
+
+ it "should be lower then 1.5 trillion" do
+ result = @scope.function_time([])
+ result.should(be < 1500000000)
+ end
+
end
lambda { @scope.function_type([]) }.should( raise_error(Puppet::ParseError))
end
- it "should return a type when given a string" do
+ it "should return String when given a string" do
result = @scope.function_type(["aaabbbbcccc"])
result.should(eq('String'))
end
+ it "should return Array when given an array" do
+ result = @scope.function_type([["aaabbbbcccc","asdf"]])
+ result.should(eq('Array'))
+ end
+
+ it "should return Hash when given a hash" do
+ result = @scope.function_type([{"a"=>1,"b"=>2}])
+ result.should(eq('Hash'))
+ end
+
end