diff options
| author | Paul Berry <paul@puppetlabs.com> | 2011-02-01 16:00:17 -0800 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2011-02-01 16:00:17 -0800 |
| commit | b29f86487581d89016b63f5f7780b15d2ec8573e (patch) | |
| tree | cd8ce6fb28a7f590eb982d981210074cdea8f887 /spec | |
| parent | 846012158d08fbfbfb83d66652788a46e4eaf2c6 (diff) | |
| parent | ce5a2bf3ba66d5ce723a6887580b008e8ba4104b (diff) | |
Merge branch 'feature/master/5061' into 2.6.next
* feature/master/5061:
(#5061) - allow special hostclass/define variables to be evaluated as defaults.
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/resource/type_spec.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb index 206616ef4..87b4ab420 100755 --- a/spec/unit/resource/type_spec.rb +++ b/spec/unit/resource/type_spec.rb @@ -261,6 +261,28 @@ describe Puppet::Resource::Type do @type = Puppet::Resource::Type.new(:hostclass, "foo") end + ['module_name', 'name', 'title'].each do |variable| + it "should allow #{variable} to be evaluated as param default" do + @type.module_name = "bar" + var = Puppet::Parser::AST::Variable.new({'value' => variable}) + @type.set_arguments :foo => var + @type.set_resource_parameters(@resource, @scope) + @scope.lookupvar('foo').should == 'bar' + end + end + + # this test is to clarify a crazy edge case + # if you specify these special names as params, the resource + # will override the special variables + it "resource should override defaults" do + @type.set_arguments :name => nil + @resource[:name] = 'foobar' + var = Puppet::Parser::AST::Variable.new({'value' => 'name'}) + @type.set_arguments :foo => var + @type.set_resource_parameters(@resource, @scope) + @scope.lookupvar('foo').should == 'foobar' + end + it "should set each of the resource's parameters as variables in the scope" do @type.set_arguments :foo => nil, :boo => nil @resource[:foo] = "bar" |
