Sha256: c2a2435c1a4fe112eebc8d937ef3552fb673c2efa4ed0cf9451609253172c082

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'
require 'puppet/pops'
require 'puppet/loaders'

describe 'the static loader' do
  it 'has no parent' do
    expect(Puppet::Pops::Loader::StaticLoader.new.parent).to be(nil)
  end

  it 'identifies itself in string form' do
    expect(Puppet::Pops::Loader::StaticLoader.new.to_s).to be_eql('(StaticLoader)')
  end

  it 'support the Loader API' do
    # it may produce things later, this is just to test that calls work as they should - now all lookups are nil.
    loader = Puppet::Pops::Loader::StaticLoader.new()
    a_typed_name = typed_name(:function, 'foo')
    expect(loader[a_typed_name]).to be(nil)
    expect(loader.load_typed(a_typed_name)).to be(nil)
    expect(loader.find(a_typed_name)).to be(nil)
  end

  context 'provides access to logging functions' do
    let(:loader) { loader = Puppet::Pops::Loader::StaticLoader.new() }
    # Ensure all logging functions produce output
    before(:each) { Puppet::Util::Log.level = :debug }

    Puppet::Util::Log.levels.each do |level|
      it "defines the function #{level.to_s}" do
        expect(loader.load(:function, level).class.name).to eql(level.to_s)
      end

      it 'and #{level.to_s} can be called' do
        expect(loader.load(:function, level).call({}, 'yay').to_s).to eql('yay')
      end

      it "uses the evaluator to format output" do
        expect(loader.load(:function, level).call({}, ['yay', 'surprise']).to_s).to eql('[yay, surprise]')
      end
    end
  end

  def typed_name(type, name)
    Puppet::Pops::Loader::Loader::TypedName.new(type, name)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
puppet-3.6.2 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.2-x86-mingw32 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.1 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.1-x86-mingw32 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.0 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.0-x86-mingw32 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.0.rc1 spec/unit/pops/loaders/static_loader_spec.rb
puppet-3.6.0.rc1-x86-mingw32 spec/unit/pops/loaders/static_loader_spec.rb