diff options
author | Adrien Thebo <git@somethingsinistral.net> | 2013-03-18 15:38:07 -0700 |
---|---|---|
committer | Adrien Thebo <git@somethingsinistral.net> | 2013-03-18 15:38:07 -0700 |
commit | 2c1b2c07c2d09464377cbde7b21952c99877751c (patch) | |
tree | 14588238bdad3432042f0177201869f14fd8b047 | |
parent | 292490b0adefa9385a1940431f15332724f1c6b4 (diff) | |
parent | c0a0682706ccc1ed8c927c5529c08ffe2a7a4a5e (diff) | |
download | puppet-stdlib-2c1b2c07c2d09464377cbde7b21952c99877751c.tar.gz puppet-stdlib-2c1b2c07c2d09464377cbde7b21952c99877751c.tar.bz2 |
Merge branch '3.x' into 4.x
-rw-r--r-- | lib/puppet/parser/functions/str2bool.rb | 5 | ||||
-rw-r--r-- | spec/unit/puppet/parser/functions/str2bool_spec.rb | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/puppet/parser/functions/str2bool.rb b/lib/puppet/parser/functions/str2bool.rb index c320da6..9ea6dd5 100644 --- a/lib/puppet/parser/functions/str2bool.rb +++ b/lib/puppet/parser/functions/str2bool.rb @@ -14,6 +14,11 @@ like: 0, f, n, false, no to 'false'. "given (#{arguments.size} for 1)") if arguments.size < 1 string = arguments[0] + + # If string is already Boolean, return it + if !!string == string + return string + end unless string.is_a?(String) raise(Puppet::ParseError, 'str2bool(): Requires either ' + diff --git a/spec/unit/puppet/parser/functions/str2bool_spec.rb b/spec/unit/puppet/parser/functions/str2bool_spec.rb index 2782bbe..ef6350f 100644 --- a/spec/unit/puppet/parser/functions/str2bool_spec.rb +++ b/spec/unit/puppet/parser/functions/str2bool_spec.rb @@ -21,4 +21,11 @@ describe "the str2bool function" do result = scope.function_str2bool(["undef"]) result.should(eq(false)) 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 |