1 #! /usr/bin/env ruby -S rspec
4 describe "the str2bool function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("str2bool")).to eq("function_str2bool")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_str2bool([]) }.to( raise_error(Puppet::ParseError))
15 it "should convert string 'true' to true" do
16 result = scope.function_str2bool(["true"])
17 expect(result).to(eq(true))
20 it "should convert string 'undef' to false" do
21 result = scope.function_str2bool(["undef"])
22 expect(result).to(eq(false))
25 it "should return the boolean it was called with" do
26 result = scope.function_str2bool([true])
27 expect(result).to(eq(true))
28 result = scope.function_str2bool([false])
29 expect(result).to(eq(false))