Sha256: 87a42ee4c5e7310dc78bbc1b69112aed8ae8c2bee8844c10c6cae1ed30def0db

Contents?: true

Size: 958 Bytes

Versions: 6

Compression:

Stored size: 958 Bytes

Contents

require 'spec_helper'
require 'hiera_puppet'
require 'puppet/parser/functions/hiera_include'

describe 'Puppet::Parser::Functions#hiera_include' do
  let :scope do Puppet::Parser::Scope.new_for_test_harness('foo') end

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

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

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

  it 'should use the array resolution_type' do
    HieraPuppet.expects(:lookup).with() { |*args| args[4].should be :array }.returns(['someclass'])
    expect { scope.function_hiera_include(['key']) }.to raise_error Puppet::Error, /Could not find class someclass/
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.1.1 spec/unit/parser/functions/hiera_include_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.1.0 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.1.0.rc2 spec/unit/parser/functions/hiera_include_spec.rb
puppet-3.1.0.rc1 spec/unit/parser/functions/hiera_include_spec.rb