]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/unit/puppet/functions/type_of_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / unit / puppet / functions / type_of_spec.rb
1 #! /usr/bin/env ruby -S rspec
2
3 require 'spec_helper'
4
5 if ENV["FUTURE_PARSER"] == 'yes' or Puppet.version >= "4"
6   require 'puppet/pops'
7   require 'puppet/loaders'
8
9   describe 'the type_of function' do
10     before(:all) do
11       loaders = Puppet::Pops::Loaders.new(Puppet::Node::Environment.create(:testing, [File.join(fixtures, "modules")]))
12       Puppet.push_context({:loaders => loaders}, "test-examples")
13     end
14
15     after(:all) do
16       Puppet::Pops::Loaders.clear
17       Puppet::pop_context()
18     end
19
20     let(:func) do
21       # Load the function from the environment modulepath's modules (ie, fixtures)
22       Puppet.lookup(:loaders).private_environment_loader.load(:function, 'type_of')
23     end
24
25     it 'gives the type of a string' do
26       expect(func.call({}, 'hello world')).to be_kind_of(Puppet::Pops::Types::PStringType)
27     end
28
29     it 'gives the type of an integer' do
30       expect(func.call({}, 5)).to be_kind_of(Puppet::Pops::Types::PIntegerType)
31     end
32   end
33 end