Sha256: f9f181fda0dd2b95a4d71837578b0f76e2ef784e02b403dd6b7bb3b3dac29e92

Contents?: true

Size: 941 Bytes

Versions: 420

Compression:

Stored size: 941 Bytes

Contents

require 'spec_helper'

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

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

  it 'returns the values in the hash in the order they appear in a hash iteration' do
    expect(compile_to_catalog(<<-'SRC'.unindent)).to have_resource('Notify[1 & 2]')
        $k = {'apples' => 1, 'oranges' => 2}.values
        notify { "${k[0]} & ${k[1]}": }
      SRC
  end

  it 'returns an empty array for an empty hash' do
    expect(compile_to_catalog(<<-'SRC'.unindent)).to have_resource('Notify[0]')
        $v = {}.values.reduce(0) |$m, $v| { $m+1 }
        notify { "${v}": }
      SRC
  end

  it 'includes an undef value if one is present in the hash' do
    expect(compile_to_catalog(<<-'SRC'.unindent)).to have_resource('Notify[Undef]')
        $types = {a => undef}.values.map |$v| { $v.type }
        notify { "${types[0]}": }
    SRC
  end
end

Version data entries

420 entries across 420 versions & 1 rubygems

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