1 #! /usr/bin/env ruby -S rspec
4 describe "the type function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
7 expect(Puppet::Parser::Functions.function("type")).to eq("function_type")
10 it "should give a deprecation warning when called" do
11 scope.expects(:warning).with("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.")
12 scope.function_type(["aoeu"])
15 it "should return string when given a string" do
16 result = scope.function_type(["aaabbbbcccc"])
17 expect(result).to(eq('string'))
20 it "should return array when given an array" do
21 result = scope.function_type([["aaabbbbcccc","asdf"]])
22 expect(result).to(eq('array'))
25 it "should return hash when given a hash" do
26 result = scope.function_type([{"a"=>1,"b"=>2}])
27 expect(result).to(eq('hash'))
30 it "should return integer when given an integer" do
31 result = scope.function_type(["1"])
32 expect(result).to(eq('integer'))
35 it "should return float when given a float" do
36 result = scope.function_type(["1.34"])
37 expect(result).to(eq('float'))
40 it "should return boolean when given a boolean" do
41 result = scope.function_type([true])
42 expect(result).to(eq('boolean'))