diff options
-rw-r--r-- | lib/puppet/resource/type.rb | 1 | ||||
-rwxr-xr-x | spec/unit/resource/type_spec.rb | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 6296d26e5..f6d378512 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -69,6 +69,7 @@ class Puppet::Resource::Type end scope = subscope(scope, resource) unless resource.title == :main + scope.compiler.add_class(name) unless definition? set_resource_parameters(resource, scope) diff --git a/spec/unit/resource/type_spec.rb b/spec/unit/resource/type_spec.rb index 4d3942c5c..f58092ec5 100755 --- a/spec/unit/resource/type_spec.rb +++ b/spec/unit/resource/type_spec.rb @@ -412,6 +412,23 @@ describe Puppet::Resource::Type do @type = Puppet::Resource::Type.new(:hostclass, "foo") end + it "should add hostclass names to the classes list" do + @type.evaluate_code(@resource) + @compiler.catalog.classes.should be_include("foo") + end + + it "should add node names to the classes list" do + @type = Puppet::Resource::Type.new(:node, "foo") + @type.evaluate_code(@resource) + @compiler.catalog.classes.should be_include("foo") + end + + it "should not add defined resource names to the classes list" do + @type = Puppet::Resource::Type.new(:definition, "foo") + @type.evaluate_code(@resource) + @compiler.catalog.classes.should_not be_include("foo") + end + it "should set all of its parameters in a subscope" do subscope = stub 'subscope', :compiler => @compiler @type.expects(:subscope).with(@scope, @resource).returns subscope |