Sha256: acb3f67a42e3f0acd988b2fd7ef850ad781cd6801a75d07cea5a3a70d9ca5faf

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 strip function' do
  include PuppetSpec::Compiler
  include Matchers::Resource

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

  it 'returns the value if Numeric' do
    expect(compile_to_catalog("notify { String(42.strip == 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 '].strip == ['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.strip == ['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']].strip")}.to raise_error(/'strip' 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.3.0 spec/unit/functions/strip_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/functions/strip_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/functions/strip_spec.rb
puppet-8.3.0-universal-darwin spec/unit/functions/strip_spec.rb
puppet-8.4.0 spec/unit/functions/strip_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/functions/strip_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/functions/strip_spec.rb
puppet-8.4.0-universal-darwin spec/unit/functions/strip_spec.rb
puppet-7.28.0 spec/unit/functions/strip_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/functions/strip_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/functions/strip_spec.rb
puppet-7.28.0-universal-darwin spec/unit/functions/strip_spec.rb
puppet-8.3.1 spec/unit/functions/strip_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/functions/strip_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/functions/strip_spec.rb
puppet-8.3.1-universal-darwin spec/unit/functions/strip_spec.rb
puppet-7.27.0 spec/unit/functions/strip_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/functions/strip_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/functions/strip_spec.rb
puppet-7.27.0-universal-darwin spec/unit/functions/strip_spec.rb