summaryrefslogtreecommitdiff
path: root/spec/unit/puppet/parser/functions
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-04-01 09:37:15 -0700
committerAdrien Thebo <git@somethingsinistral.net>2013-04-01 09:37:15 -0700
commitf90c54e2df6e8cbd8490a59c7429938072dc1b8d (patch)
treea946ee1edb5862430106b35150d82aef3a61d8fe /spec/unit/puppet/parser/functions
parent4078a6ff44c3ea8c2a071eec3bd7b02dabc770d7 (diff)
parentc372f177708df4c844337e9901646b7b84b86cd8 (diff)
Merge pull request #139 from hakamadare/19864_num2bool_match_fix
(19864) num2bool match fix
Diffstat (limited to 'spec/unit/puppet/parser/functions')
-rw-r--r--spec/unit/puppet/parser/functions/num2bool_spec.rb49
1 files changed, 46 insertions, 3 deletions
diff --git a/spec/unit/puppet/parser/functions/num2bool_spec.rb b/spec/unit/puppet/parser/functions/num2bool_spec.rb
index 640c689..b56196d 100644
--- a/spec/unit/puppet/parser/functions/num2bool_spec.rb
+++ b/spec/unit/puppet/parser/functions/num2bool_spec.rb
@@ -8,17 +8,60 @@ describe "the num2bool function" do
Puppet::Parser::Functions.function("num2bool").should == "function_num2bool"
end
- it "should raise a ParseError if there is less than 1 arguments" do
+ it "should raise a ParseError if there are no arguments" do
lambda { scope.function_num2bool([]) }.should( raise_error(Puppet::ParseError))
end
- it "should return true if 1" do
+ it "should raise a ParseError if there are more than 1 arguments" do
+ lambda { scope.function_num2bool(["foo","bar"]) }.should( raise_error(Puppet::ParseError))
+ end
+
+ it "should raise a ParseError if passed something non-numeric" do
+ lambda { scope.function_num2bool(["xyzzy"]) }.should( raise_error(Puppet::ParseError))
+ end
+
+ it "should return true if passed string 1" do
result = scope.function_num2bool(["1"])
result.should(be_true)
end
- it "should return false if 0" do
+ it "should return true if passed string 1.5" do
+ result = scope.function_num2bool(["1.5"])
+ result.should(be_true)
+ end
+
+ it "should return true if passed number 1" do
+ result = scope.function_num2bool([1])
+ result.should(be_true)
+ end
+
+ it "should return false if passed string 0" do
result = scope.function_num2bool(["0"])
result.should(be_false)
end
+
+ it "should return false if passed number 0" do
+ result = scope.function_num2bool([0])
+ result.should(be_false)
+ end
+
+ it "should return false if passed string -1" do
+ result = scope.function_num2bool(["-1"])
+ result.should(be_false)
+ end
+
+ it "should return false if passed string -1.5" do
+ result = scope.function_num2bool(["-1.5"])
+ result.should(be_false)
+ end
+
+ it "should return false if passed number -1" do
+ result = scope.function_num2bool([-1])
+ result.should(be_false)
+ end
+
+ it "should return false if passed float -1.5" do
+ result = scope.function_num2bool([-1.5])
+ result.should(be_false)
+ end
end