4 describe "the type function" do
6 Puppet::Parser::Functions.autoloader.loadall
10 @scope = Puppet::Parser::Scope.new
14 Puppet::Parser::Functions.function("type").should == "function_type"
17 it "should raise a ParseError if there is less than 1 arguments" do
18 lambda { @scope.function_type([]) }.should( raise_error(Puppet::ParseError))
21 it "should return string when given a string" do
22 result = @scope.function_type(["aaabbbbcccc"])
23 result.should(eq('string'))
26 it "should return array when given an array" do
27 result = @scope.function_type([["aaabbbbcccc","asdf"]])
28 result.should(eq('array'))
31 it "should return hash when given a hash" do
32 result = @scope.function_type([{"a"=>1,"b"=>2}])
33 result.should(eq('hash'))
36 it "should return integer when given an integer" do
37 result = @scope.function_type(["1"])
38 result.should(eq('integer'))
41 it "should return float when given a float" do
42 result = @scope.function_type(["1.34"])
43 result.should(eq('float'))
46 it "should return boolean when given a boolean" do
47 result = @scope.function_type([true])
48 result.should(eq('boolean'))