Sha256: 0ef0effa627ea5c6ae8e05e3e82fce6308e1f18248dcd321ad4d82d4f5fd6403

Contents?: true

Size: 1.29 KB

Versions: 18

Compression:

Stored size: 1.29 KB

Contents

shared_examples_for 'all iterative functions hash handling' do |func|
  it 'passes a hash entry as an array of the key and value' do
    catalog = compile_to_catalog(<<-MANIFEST)
      {a=>1}.#{func} |$v| { notify { "${v[0]} ${v[1]}": } }
    MANIFEST

    catalog.resource(:notify, "a 1").should_not be_nil
  end
end

shared_examples_for 'all iterative functions argument checks' do |func|

  it 'raises an error when used against an unsupported type' do
    expect do
      compile_to_catalog(<<-MANIFEST)
        3.14.#{func} |$v| {  }
      MANIFEST
    end.to raise_error(Puppet::Error, /must be something enumerable/)
  end

  it 'raises an error when called with any parameters besides a block' do
    expect do
      compile_to_catalog(<<-MANIFEST)
        [1].#{func}(1) |$v| {  }
      MANIFEST
    end.to raise_error(Puppet::Error, /Wrong number of arguments/)
  end

  it 'raises an error when called without a block' do
    expect do
      compile_to_catalog(<<-MANIFEST)
        [1].#{func}()
      MANIFEST
    end.to raise_error(Puppet::Error, /Wrong number of arguments/)
  end

  it 'raises an error when called without a block' do
    expect do
      compile_to_catalog(<<-MANIFEST)
        [1].#{func}(1)
      MANIFEST
    end.to raise_error(Puppet::Error, /must be a parameterized block/)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
puppet-3.6.2 spec/unit/parser/methods/shared.rb
puppet-3.6.2-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.6.1 spec/unit/parser/methods/shared.rb
puppet-3.6.1-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.6.0 spec/unit/parser/methods/shared.rb
puppet-3.6.0-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.6.0.rc1 spec/unit/parser/methods/shared.rb
puppet-3.6.0.rc1-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.5.1 spec/unit/parser/methods/shared.rb
puppet-3.5.1-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.5.1.rc1 spec/unit/parser/methods/shared.rb
puppet-3.5.1.rc1-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.5.0.rc3 spec/unit/parser/methods/shared.rb
puppet-3.5.0.rc3-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.5.0.rc2 spec/unit/parser/methods/shared.rb
puppet-3.5.0.rc2-x86-mingw32 spec/unit/parser/methods/shared.rb
puppet-3.5.0.rc1 spec/unit/parser/methods/shared.rb
puppet-3.5.0.rc1-x86-mingw32 spec/unit/parser/methods/shared.rb