]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/type3x_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / type3x_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the type3x function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6   it "should exist" do
7     expect(Puppet::Parser::Functions.function("type3x")).to eq("function_type3x")
8   end
9
10   it "should raise a ParseError if there is less than 1 arguments" do
11     expect { scope.function_type3x([]) }.to( raise_error(Puppet::ParseError))
12   end
13
14   it "should return string when given a string" do
15     result = scope.function_type3x(["aaabbbbcccc"])
16     expect(result).to(eq('string'))
17   end
18
19   it "should return array when given an array" do
20     result = scope.function_type3x([["aaabbbbcccc","asdf"]])
21     expect(result).to(eq('array'))
22   end
23
24   it "should return hash when given a hash" do
25     result = scope.function_type3x([{"a"=>1,"b"=>2}])
26     expect(result).to(eq('hash'))
27   end
28
29   it "should return integer when given an integer" do
30     result = scope.function_type3x(["1"])
31     expect(result).to(eq('integer'))
32   end
33
34   it "should return float when given a float" do
35     result = scope.function_type3x(["1.34"])
36     expect(result).to(eq('float'))
37   end
38
39   it "should return boolean when given a boolean" do
40     result = scope.function_type3x([true])
41     expect(result).to(eq('boolean'))
42   end
43 end