]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/type_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / type_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the type function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6   it "should exist" do
7     expect(Puppet::Parser::Functions.function("type")).to eq("function_type")
8   end
9
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"])
13   end
14
15   it "should return string when given a string" do
16     result = scope.function_type(["aaabbbbcccc"])
17     expect(result).to(eq('string'))
18   end
19
20   it "should return array when given an array" do
21     result = scope.function_type([["aaabbbbcccc","asdf"]])
22     expect(result).to(eq('array'))
23   end
24
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'))
28   end
29
30   it "should return integer when given an integer" do
31     result = scope.function_type(["1"])
32     expect(result).to(eq('integer'))
33   end
34
35   it "should return float when given a float" do
36     result = scope.function_type(["1.34"])
37     expect(result).to(eq('float'))
38   end
39
40   it "should return boolean when given a boolean" do
41     result = scope.function_type([true])
42     expect(result).to(eq('boolean'))
43   end
44 end