Sha256: 9e0d8d842c9774412eaa2f70fc2b213d5a56b4639be1de631170fc4caff2f520

Contents?: true

Size: 1.05 KB

Versions: 576

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

require 'puppet_spec/compiler'
require 'matchers/resource'

describe 'the lest function' do
  include PuppetSpec::Compiler
  include Matchers::Resource

  it 'calls a lambda passing no argument' do
    expect(compile_to_catalog("lest(undef) || { notify { testing: } }")).to have_resource('Notify[testing]')
  end

  it 'produces what lambda returns if value is undef' do
    expect(compile_to_catalog("notify{ lest(undef) || { testing }: }")).to have_resource('Notify[testing]')
  end

  it 'does not call lambda if argument is not undef' do
    expect(compile_to_catalog('lest(1) || { notify { "failed": } }')).to_not have_resource('Notify[failed]')
  end

  it 'produces given argument if given not undef' do
    expect(compile_to_catalog(<<-SOURCE)).to have_resource('Notify[test_yay_ing]')
    notify{ "test${lest('_yay_') || { '_oh_no_' }}ing": }
    SOURCE
  end

  it 'errors when lambda wants too many args' do
    expect do
      compile_to_catalog('lest(1) |$x| { }')
    end.to raise_error(/'lest' block expects no arguments, got 1/m)
  end

end

Version data entries

576 entries across 576 versions & 1 rubygems

Version Path
puppet-7.24.0 spec/unit/functions/lest_spec.rb
puppet-7.24.0-x86-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.24.0-x64-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.24.0-universal-darwin spec/unit/functions/lest_spec.rb
puppet-7.23.0 spec/unit/functions/lest_spec.rb
puppet-7.23.0-x86-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.23.0-x64-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.23.0-universal-darwin spec/unit/functions/lest_spec.rb
puppet-7.22.0 spec/unit/functions/lest_spec.rb
puppet-7.22.0-x86-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.22.0-x64-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.22.0-universal-darwin spec/unit/functions/lest_spec.rb
puppet-6.29.0 spec/unit/functions/lest_spec.rb
puppet-6.29.0-x86-mingw32 spec/unit/functions/lest_spec.rb
puppet-6.29.0-x64-mingw32 spec/unit/functions/lest_spec.rb
puppet-6.29.0-universal-darwin spec/unit/functions/lest_spec.rb
puppet-7.21.0 spec/unit/functions/lest_spec.rb
puppet-7.21.0-x86-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.21.0-x64-mingw32 spec/unit/functions/lest_spec.rb
puppet-7.21.0-universal-darwin spec/unit/functions/lest_spec.rb