File: hiera_array_spec.rb

package info (click to toggle)
puppet 3.7.2-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 18,896 kB
  • sloc: ruby: 210,387; sh: 2,050; xml: 1,554; lisp: 300; makefile: 142; python: 108; sql: 103; yacc: 72
file content (26 lines) | stat: -rw-r--r-- 843 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'spec_helper'
require 'puppet_spec/scope'

describe 'Puppet::Parser::Functions#hiera_array' do
  include PuppetSpec::Scope

  before :each do
    Puppet[:hiera_config] = PuppetSpec::Files.tmpfile('hiera_config')
  end

  let :scope do create_test_scope_for_node('foo') end

  it 'should require a key argument' do
    expect { scope.function_hiera_array([]) }.to raise_error(ArgumentError)
  end

  it 'should raise a useful error when nil is returned' do
    Hiera.any_instance.expects(:lookup).returns(nil)
    expect { scope.function_hiera_array(["badkey"]) }.to raise_error(Puppet::ParseError, /Could not find data item badkey/ )
  end

  it 'should use the array resolution_type' do
    Hiera.any_instance.expects(:lookup).with() { |*args| args[4].should be(:array) }.returns([])
    scope.function_hiera_array(['key'])
  end
end