Sha256: fe35b69ef1515e5a98d22f19d280811ee58b08dc376629c153cc0d4a78e2ef3b

Contents?: true

Size: 1.02 KB

Versions: 348

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

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

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

  it 'converts and returns the converted when no lambda is given' do
    expect(compile_to_catalog('notify{ "testing-${[a,1].convert_to(Hash) =~ Hash}": }')).to have_resource('Notify[testing-true]')
  end

  it 'converts given value to instance of type and calls a lambda with converted value' do
    expect(compile_to_catalog('"1".convert_to(Integer) |$x| { notify { "testing-${x.type(generalized)}": } }')).to have_resource('Notify[testing-Integer]')
  end

  it 'returns the lambda return when lambda is given' do
    expect(compile_to_catalog('notify{ "testing-${[a,1].convert_to(Hash) |$x| { yay }}": }')).to have_resource('Notify[testing-yay]')
  end

  it 'passes on additional arguments to the new function' do
    expect(compile_to_catalog('"111".convert_to(Integer, 2) |$x| { notify { "testing-${x}": } }')).to have_resource('Notify[testing-7]')
  end
end

Version data entries

348 entries across 348 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/functions/convert_to_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-8.3.0-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-8.4.0 spec/unit/functions/convert_to_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-8.4.0-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-7.28.0 spec/unit/functions/convert_to_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-7.28.0-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-8.3.1 spec/unit/functions/convert_to_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-8.3.1-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-7.27.0 spec/unit/functions/convert_to_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-7.27.0-universal-darwin spec/unit/functions/convert_to_spec.rb