Sha256: 56850ca740d11503aeb733a69f3b97d378cf85bbf53127a23c209023429f0785

Contents?: true

Size: 1.37 KB

Versions: 204

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

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

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

  it 'returns lower case version of a string' do
    expect(compile_to_catalog("notify { 'ABC'.downcase: }")).to have_resource('Notify[abc]')
  end

  it 'returns the value if Numeric' do
    expect(compile_to_catalog("notify { String(42.downcase == 42): }")).to have_resource('Notify[true]')
  end

  it 'performs capitalize of international UTF-8 characters', :if => RUBY_VERSION >= "2.4" do
    expect(compile_to_catalog("notify { 'ÅÄÖ'.downcase: }")).to have_resource('Notify[åäö]')
  end

  it 'returns lower case version of each entry in an array (recursively)' do
    expect(compile_to_catalog("notify { String(['A', ['B', ['C']]].downcase == ['a', ['b', ['c']]]): }")).to have_resource('Notify[true]')
  end

  it 'returns lower case version of keys and values in a hash (recursively)' do
    expect(compile_to_catalog("notify { String({'A'=>'B','C'=>{'D'=>'E'}}.downcase == {'a'=>'b', 'c'=>{'d'=>'e'}}): }")).to have_resource('Notify[true]')
  end

  it 'returns lower case version of keys and values in nested hash / array structure' do
    expect(compile_to_catalog("notify { String({'A'=>['B'],'C'=>[{'D'=>'E'}]}.downcase == {'a'=>['b'],'c'=>[{'d'=>'e'}]}): }")).to have_resource('Notify[true]')
  end

end

Version data entries

204 entries across 204 versions & 1 rubygems

Version Path
puppet-6.29.0 spec/unit/functions/downcase_spec.rb
puppet-6.29.0-x86-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.29.0-x64-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.29.0-universal-darwin spec/unit/functions/downcase_spec.rb
puppet-6.28.0 spec/unit/functions/downcase_spec.rb
puppet-6.28.0-x86-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.28.0-x64-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.28.0-universal-darwin spec/unit/functions/downcase_spec.rb
puppet-6.27.0 spec/unit/functions/downcase_spec.rb
puppet-6.27.0-x86-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.27.0-x64-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.27.0-universal-darwin spec/unit/functions/downcase_spec.rb
puppet-6.26.0 spec/unit/functions/downcase_spec.rb
puppet-6.26.0-x86-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.26.0-x64-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.26.0-universal-darwin spec/unit/functions/downcase_spec.rb
puppet-6.25.1 spec/unit/functions/downcase_spec.rb
puppet-6.25.1-x86-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.25.1-x64-mingw32 spec/unit/functions/downcase_spec.rb
puppet-6.25.1-universal-darwin spec/unit/functions/downcase_spec.rb