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.5.22 spec/unit/parser/resource/param_spec.rb
puppet-5.5.22-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.22-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.22-universal-darwin spec/unit/parser/resource/param_spec.rb
puppet-5.5.21 spec/unit/parser/resource/param_spec.rb
puppet-5.5.21-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.21-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.21-universal-darwin spec/unit/parser/resource/param_spec.rb
puppet-5.5.20 spec/unit/parser/resource/param_spec.rb
puppet-5.5.20-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.20-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.20-universal-darwin spec/unit/parser/resource/param_spec.rb
puppet-5.5.19 spec/unit/parser/resource/param_spec.rb
puppet-5.5.19-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.19-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.19-universal-darwin spec/unit/parser/resource/param_spec.rb
puppet-5.5.18 spec/unit/parser/resource/param_spec.rb
puppet-5.5.18-x86-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.18-x64-mingw32 spec/unit/parser/resource/param_spec.rb
puppet-5.5.18-universal-darwin spec/unit/parser/resource/param_spec.rb