Sha256: 16c655c06eee6b194b1b8436f1c8d3948b841c4213b0538f103f3ca1d5c46de8

Contents?: true

Size: 844 Bytes

Versions: 76

Compression:

Stored size: 844 Bytes

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

end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/unit/functions/convert_to_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.22-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-5.5.21 spec/unit/functions/convert_to_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.21-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-5.5.20 spec/unit/functions/convert_to_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.20-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-5.5.19 spec/unit/functions/convert_to_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.19-universal-darwin spec/unit/functions/convert_to_spec.rb
puppet-5.5.18 spec/unit/functions/convert_to_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/functions/convert_to_spec.rb
puppet-5.5.18-universal-darwin spec/unit/functions/convert_to_spec.rb