File: upcase_spec.rb

package info (click to toggle)
puppet-agent 7.23.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,092 kB
  • sloc: ruby: 245,074; sh: 456; makefile: 38; xml: 33
file content (34 lines) | stat: -rw-r--r-- 1,357 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'spec_helper'

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

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

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

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

  it 'performs upcase of international UTF-8 characters' do
    expect(compile_to_catalog("notify { 'åäö'.upcase: }")).to have_resource('Notify[ÅÄÖ]')
  end

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

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

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

end