Sha256: 2f686508e2c758d8e8d7e8847ebae0e69b6c9b32d92a2af708fcb34277a22be9

Contents?: true

Size: 1.33 KB

Versions: 204

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

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

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

  it 'returns initial char upper case version of a string' do
    expect(compile_to_catalog("notify { 'abc'.capitalize: }")).to have_resource('Notify[Abc]')
  end

  it 'returns the value if Numeric' do
    expect(compile_to_catalog("notify { String(42.capitalize == 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 { 'åäö'.capitalize: }")).to have_resource('Notify[Åäö]')
  end

  it 'returns capitalized version of each entry in an array' do
    expect(compile_to_catalog("notify { String(['aa', 'ba', 'ca'].capitalize == ['Aa', 'Ba', 'Ca']): }")).to have_resource('Notify[true]')
  end

  it 'returns capitalized version of each entry in an Iterator' do
    expect(compile_to_catalog("notify { String(['aa', 'ba', 'ca'].reverse_each.capitalize == ['Ca', 'Ba', 'Aa']): }")).to have_resource('Notify[true]')
  end

  it 'errors when given a a nested Array' do
    expect { compile_to_catalog("['a', 'b', ['c']].capitalize")}.to raise_error(/'capitalize' parameter 'arg' expects a value of type Numeric, String, or Iterable/)
  end

end

Version data entries

204 entries across 204 versions & 1 rubygems

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