Merge branch '3.x' into 4.x
This commit is contained in:
commit
2c1b2c07c2
2 changed files with 12 additions and 0 deletions
|
@ -14,6 +14,11 @@ like: 0, f, n, false, no to 'false'.
|
||||||
"given (#{arguments.size} for 1)") if arguments.size < 1
|
"given (#{arguments.size} for 1)") if arguments.size < 1
|
||||||
|
|
||||||
string = arguments[0]
|
string = arguments[0]
|
||||||
|
|
||||||
|
# If string is already Boolean, return it
|
||||||
|
if !!string == string
|
||||||
|
return string
|
||||||
|
end
|
||||||
|
|
||||||
unless string.is_a?(String)
|
unless string.is_a?(String)
|
||||||
raise(Puppet::ParseError, 'str2bool(): Requires either ' +
|
raise(Puppet::ParseError, 'str2bool(): Requires either ' +
|
||||||
|
|
|
@ -21,4 +21,11 @@ describe "the str2bool function" do
|
||||||
result = scope.function_str2bool(["undef"])
|
result = scope.function_str2bool(["undef"])
|
||||||
result.should(eq(false))
|
result.should(eq(false))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return the boolean it was called with" do
|
||||||
|
result = scope.function_str2bool([true])
|
||||||
|
result.should(eq(true))
|
||||||
|
result = scope.function_str2bool([false])
|
||||||
|
result.should(eq(false))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue