Sha256: d829e981778ed0362f93c1767be5c11eec62e961b4ebf461ba36d906295205b2

Contents?: true

Size: 1016 Bytes

Versions: 92

Compression:

Stored size: 1016 Bytes

Contents

require 'spec_helper'

describe Puppet::Parser::Resource::Param do
  it "has readers for all of the attributes" do
    param = Puppet::Parser::Resource::Param.new(:name => 'myparam', :value => 'foo', :file => 'foo.pp', :line => 42)

    expect(param.name).to eq(:myparam)
    expect(param.value).to eq('foo')
    expect(param.file).to eq('foo.pp')
    expect(param.line).to eq(42)
  end

  context "parameter validation" do
    it "throws an error when instantiated without a name" do
      expect {
        Puppet::Parser::Resource::Param.new(:value => 'foo')
      }.to raise_error(Puppet::Error, /name is a required option/)
    end

    it "does not require a value" do
      param = Puppet::Parser::Resource::Param.new(:name => 'myparam')

      expect(param.value).to be_nil
    end

    it "includes file/line context in errors" do
      expect {
        Puppet::Parser::Resource::Param.new(:file => 'foo.pp', :line => 42)
      }.to raise_error(Puppet::Error, /\(file: foo.pp, line: 42\)/)
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
puppet-5.4.0 spec/unit/parser/resource/param_spec.rb
puppet-5.4.0-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.4.0-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.4.0-universal-darwin spec/unit/parser/resource/param_spec.rb
puppet-5.3.5 spec/unit/parser/resource/param_spec.rb
puppet-5.3.5-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.3.5-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.3.5-universal-darwin spec/unit/parser/resource/param_spec.rb
puppet-5.3.4 spec/unit/parser/resource/param_spec.rb
puppet-5.3.4-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.3.4-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.3.4-universal-darwin spec/unit/parser/resource/param_spec.rb