Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / type_spec.rb
1 require 'spec_helper'
2
3 describe 'type' do
4   it 'exists' do
5     expect(Puppet::Parser::Functions.function('type')).to eq('function_type')
6   end
7
8   it 'gives a deprecation warning when called' do
9     expect(scope).to receive(: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.") # rubocop:disable Metrics/LineLength : Unable to reduce to required length
10     scope.function_type(['aoeu'])
11   end
12
13   it 'returns string when given a string' do
14     result = scope.function_type(['aaabbbbcccc'])
15     expect(result).to(eq('string'))
16   end
17
18   it 'returns array when given an array' do
19     result = scope.function_type([['aaabbbbcccc', 'asdf']])
20     expect(result).to(eq('array'))
21   end
22
23   it 'returns hash when given a hash' do
24     result = scope.function_type([{ 'a' => 1, 'b' => 2 }])
25     expect(result).to(eq('hash'))
26   end
27
28   it 'returns integer when given an integer' do
29     result = scope.function_type(['1'])
30     expect(result).to(eq('integer'))
31   end
32
33   it 'returns float when given a float' do
34     result = scope.function_type(['1.34'])
35     expect(result).to(eq('float'))
36   end
37
38   it 'returns boolean when given a boolean' do
39     result = scope.function_type([true])
40     expect(result).to(eq('boolean'))
41   end
42 end