1 #! /usr/bin/env ruby -S rspec
4 describe "the bool2str function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("bool2str")).to eq("function_bool2str")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_bool2str([]) }.to( raise_error(Puppet::ParseError))
15 it "should convert true to 'true'" do
16 result = scope.function_bool2str([true])
17 expect(result).to(eq('true'))
20 it "should convert true to a string" do
21 result = scope.function_bool2str([true])
22 expect(result.class).to(eq(String))
25 it "should convert false to 'false'" do
26 result = scope.function_bool2str([false])
27 expect(result).to(eq('false'))
30 it "should convert false to a string" do
31 result = scope.function_bool2str([false])
32 expect(result.class).to(eq(String))
35 it "should not accept a string" do
36 expect { scope.function_bool2str(["false"]) }.to( raise_error(Puppet::ParseError))
39 it "should not accept a nil value" do
40 expect { scope.function_bool2str([nil]) }.to( raise_error(Puppet::ParseError))
43 it "should not accept an undef" do
44 expect { scope.function_bool2str([:undef]) }.to( raise_error(Puppet::ParseError))