Sha256: 19e2b032811aa8c007c92863ac37ef0e7fbbb4fdb8ef6d3166d3072f0ae049fc

Contents?: true

Size: 1.1 KB

Versions: 348

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

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

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

  it 'removes trailing whitepsace' do
    expect(compile_to_catalog("notify { String(\" abc\t\n \".rstrip == ' abc'): }")).to have_resource('Notify[true]')
  end

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

  it 'returns rstripped version of each entry in an array' do
    expect(compile_to_catalog("notify { String([' a ', ' b ', ' c '].rstrip == [' a', ' b', ' c']): }")).to have_resource('Notify[true]')
  end

  it 'returns rstripped version of each entry in an Iterator' do
    expect(compile_to_catalog("notify { String(['a ', 'b ', 'c '].reverse_each.lstrip == ['c ', 'b ', 'a ']): }")).to have_resource('Notify[true]')
  end

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

end

Version data entries

348 entries across 348 versions & 1 rubygems

Version Path
puppet-8.2.0 spec/unit/functions/rstrip_spec.rb
puppet-8.2.0-x86-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-8.2.0-x64-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-8.2.0-universal-darwin spec/unit/functions/rstrip_spec.rb
puppet-7.26.0 spec/unit/functions/rstrip_spec.rb
puppet-7.26.0-x86-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-7.26.0-x64-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-7.26.0-universal-darwin spec/unit/functions/rstrip_spec.rb
puppet-7.25.0 spec/unit/functions/rstrip_spec.rb
puppet-7.25.0-x86-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-7.25.0-x64-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-7.25.0-universal-darwin spec/unit/functions/rstrip_spec.rb
puppet-8.1.0 spec/unit/functions/rstrip_spec.rb
puppet-8.1.0-x86-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-8.1.0-x64-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-8.1.0-universal-darwin spec/unit/functions/rstrip_spec.rb
puppet-8.0.1 spec/unit/functions/rstrip_spec.rb
puppet-8.0.1-x86-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-8.0.1-x64-mingw32 spec/unit/functions/rstrip_spec.rb
puppet-8.0.1-universal-darwin spec/unit/functions/rstrip_spec.rb