1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
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
|