1 #! /usr/bin/env ruby -S rspec
4 describe "the bool2num function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("bool2num")).to eq("function_bool2num")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_bool2num([]) }.to( raise_error(Puppet::ParseError))
15 it "should convert true to 1" do
16 result = scope.function_bool2num([true])
17 expect(result).to(eq(1))
20 it "should convert 'true' to 1" do
21 result = scope.function_bool2num(['true'])
25 it "should convert 'false' to 0" do
26 result = scope.function_bool2num(['false'])
27 expect(result).to(eq(0))
30 it "should accept objects which extend String" do
31 class AlsoString < String
34 value = AlsoString.new('true')
35 result = scope.function_bool2num([value])