1 #! /usr/bin/env ruby -S rspec
4 describe "the is_bool function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("is_bool")).to eq("function_is_bool")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_is_bool([]) }.to( raise_error(Puppet::ParseError))
15 it "should return true if passed a TrueClass" do
16 result = scope.function_is_bool([true])
17 expect(result).to(eq(true))
20 it "should return true if passed a FalseClass" do
21 result = scope.function_is_bool([false])
22 expect(result).to(eq(true))
25 it "should return false if passed the string 'true'" do
26 result = scope.function_is_bool(['true'])
27 expect(result).to(eq(false))
30 it "should return false if passed the string 'false'" do
31 result = scope.function_is_bool(['false'])
32 expect(result).to(eq(false))
35 it "should return false if passed an array" do
36 result = scope.function_is_bool([["a","b"]])
37 expect(result).to(eq(false))
40 it "should return false if passed a hash" do
41 result = scope.function_is_bool([{"a" => "b"}])
42 expect(result).to(eq(false))