[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Paul Berry paul at puppetlabs.com
Tue May 10 08:00:26 UTC 2011


The following commit has been merged in the experimental branch:
commit 80adb39d1f4e87fe2fa12bd03df335fc285c0bb6
Merge: 2279fe12b32bd626066d9b7637367fcbb293c29b 244213c856f3753dd3e06c5f01003f6a0d3f77ef
Author: Paul Berry <paul at puppetlabs.com>
Date:   Tue Nov 9 15:11:36 2010 -0800

    Merge commit '2.6.3rc2' into next
    
    Manually resolved conflicts:
    	lib/puppet/parser/ast/resource.rb
    	spec/unit/parser/ast/resource_spec.rb

diff --combined lib/puppet/parser/ast/resource.rb
index bd15d99,b019e6a..ce3c499
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@@ -3,15 -3,26 +3,15 @@@ require 'puppet/parser/ast/resource_ref
  # Any normal puppet resource declaration.  Can point to a definition or a
  # builtin type.
  class Puppet::Parser::AST
 -class Resource < AST::ResourceReference
 +class Resource < AST::Branch
  
    associates_doc
  
 -  attr_accessor :title, :type, :exported, :virtual
 -  attr_reader :parameters
 +  attr_accessor :type, :instances, :exported, :virtual
  
    # Does not actually return an object; instead sets an object
    # in the current scope.
    def evaluate(scope)
 -    # Evaluate all of the specified params.
 -    paramobjects = parameters.collect { |param|
 -      param.safeevaluate(scope)
 -    }
 -
 -    resource_titles = @title.safeevaluate(scope)
 -
 -    # it's easier to always use an array, even for only one name
 -    resource_titles = [resource_titles] unless resource_titles.is_a?(Array)
 -
      # We want virtual to be true if exported is true.  We can't
      # just set :virtual => self.virtual in the initialization,
      # because sometimes the :virtual attribute is set *after*
@@@ -19,48 -30,46 +19,49 @@@
      # is true.  Argh, this was a very tough one to track down.
      virt = self.virtual || self.exported
  
 -    # This is where our implicit iteration takes place; if someone
 -    # passed an array as the name, then we act just like the called us
 -    # many times.
 -    fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles)
 +    # First level of implicit iteration: build a resource for each
 +    # instance.  This handles things like:
 +    # file { '/foo': owner => blah; '/bar': owner => blah }
 +    @instances.collect { |instance|
  
 -    resource_titles.flatten.collect { |resource_title|
 -      exceptwrap :type => Puppet::ParseError do
 -        resource = Puppet::Parser::Resource.new(
 -          fully_qualified_type, resource_title,
 -          :parameters => paramobjects,
 -          :file => self.file,
 -          :line => self.line,
 -          :exported => self.exported,
 -          :virtual => virt,
 -          :source => scope.source,
 -          :scope => scope,
 -          :strict => true
 -        )
 +      # Evaluate all of the specified params.
 +      paramobjects = instance.parameters.collect { |param|
 +        param.safeevaluate(scope)
 +      }
  
 -        if resource.resource_type.is_a? Puppet::Resource::Type
 -          resource.resource_type.instantiate_resource(scope, resource)
 -        end
 -        scope.compiler.add_resource(scope, resource)
 -        scope.compiler.evaluate_classes([resource_title],scope,false) if fully_qualified_type == 'class'
 -        resource
 -      end
 -    }.reject { |resource| resource.nil? }
 -  end
 +      resource_titles = instance.title.safeevaluate(scope)
  
 -  # Set the parameters for our object.
 -  def parameters=(params)
 -    if params.is_a?(AST::ASTArray)
 -      @parameters = params
 -    else
 -      @parameters = AST::ASTArray.new(
 -        :line => params.line,
 -        :file => params.file,
 -        :children => [params]
 -      )
 -    end
 +      # it's easier to always use an array, even for only one name
 +      resource_titles = [resource_titles] unless resource_titles.is_a?(Array)
 +
 +      fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles)
 +
 +      # Second level of implicit iteration; build a resource for each
 +      # title.  This handles things like:
 +      # file { ['/foo', '/bar']: owner => blah }
 +      resource_titles.flatten.collect { |resource_title|
 +        exceptwrap :type => Puppet::ParseError do
 +          resource = Puppet::Parser::Resource.new(
 +            fully_qualified_type, resource_title,
 +            :parameters => paramobjects,
 +            :file => self.file,
 +            :line => self.line,
 +            :exported => self.exported,
 +            :virtual => virt,
 +            :source => scope.source,
 +            :scope => scope,
 +            :strict => true
 +          )
 +
-           # And then store the resource in the compiler.
-           # At some point, we need to switch all of this to return
-           # resources instead of storing them like this.
++          if resource.resource_type.is_a? Puppet::Resource::Type
++            resource.resource_type.instantiate_resource(scope, resource)
++          end
 +          scope.compiler.add_resource(scope, resource)
++          scope.compiler.evaluate_classes([resource_title],scope,false) if fully_qualified_type == 'class'
 +          resource
 +        end
 +      }
 +    }.flatten.reject { |resource| resource.nil? }
    end
  end
  end
diff --combined lib/puppet/resource/type.rb
index 3edf286,d40adc1..7782484
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@@ -13,8 -13,8 +13,8 @@@ class Puppet::Resource::Typ
  
    RESOURCE_SUPERTYPES = [:hostclass, :node, :definition]
  
 -  attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection, :module_name
 -  attr_reader :type, :namespace, :arguments, :behaves_like
 +  attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
 +  attr_reader :type, :namespace, :arguments, :behaves_like, :module_name
  
    RESOURCE_SUPERTYPES.each do |t|
      define_method("#{t}?") { self.type == t }
@@@ -92,8 -92,6 +92,8 @@@
      end
  
      set_arguments(options[:arguments])
 +
 +    @module_name = options[:module_name]
    end
  
    # This is only used for node names, and really only when the node name
@@@ -140,21 -138,15 +140,15 @@@
      end
    end
  
-   # Make an instance of our resource type.  This is only possible
-   # for those classes and nodes that don't have any arguments, and is
-   # only useful for things like the 'include' function.
-   def mk_plain_resource(scope)
+   # Make an instance of the resource type, and place it in the catalog
+   # if it isn't in the catalog already.  This is only possible for
+   # classes and nodes.  No parameters are be supplied--if this is a
+   # parameterized class, then all parameters take on their default
+   # values.
+   def ensure_in_catalog(scope)
      type == :definition and raise ArgumentError, "Cannot create resources for defined resource types"
      resource_type = type == :hostclass ? :class : :node
  
-     # Make sure our parent class has been evaluated, if we have one.
-     if parent
-       parent_resource = scope.catalog.resource(resource_type, parent)
-       unless parent_resource
-         parent_type(scope).mk_plain_resource(scope)
-       end
-     end
- 
      # Do nothing if the resource already exists; this makes sure we don't
      # get multiple copies of the class resource, which helps provide the
      # singleton nature of classes.
@@@ -163,11 -155,22 +157,22 @@@
      end
  
      resource = Puppet::Parser::Resource.new(resource_type, name, :scope => scope, :source => self)
+     instantiate_resource(scope, resource)
      scope.compiler.add_resource(scope, resource)
      resource
    end
  
+   def instantiate_resource(scope, resource)
+     # Make sure our parent class has been evaluated, if we have one.
+     if parent && !scope.catalog.resource(resource.type, parent)
+       parent_type(scope).ensure_in_catalog(scope)
+     end
+ 
+     if ['Class', 'Node'].include? resource.type
+       scope.catalog.tag(*resource.tags)
+     end
+   end
+ 
    def name
      return @name unless @name.is_a?(Regexp)
      @name.source.downcase.gsub(/[^-\w:.]/,'').sub(/^\.+/,'')
diff --combined spec/unit/parser/ast/resource_spec.rb
index a8e7832,e1f73e1..3ed7b3e
--- a/spec/unit/parser/ast/resource_spec.rb
+++ b/spec/unit/parser/ast/resource_spec.rb
@@@ -5,134 -5,168 +5,180 @@@ require File.dirname(__FILE__) + '/../.
  describe Puppet::Parser::AST::Resource do
    ast = Puppet::Parser::AST
  
-   before :each do
-     @title = Puppet::Parser::AST::String.new(:value => "mytitle")
-     @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
-     @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
-     @scope.stubs(:resource).returns(stub_everything)
-     @instance = ast::ResourceInstance.new(:title => @title, :parameters => ast::ASTArray.new(:children => []))
-     @resource = ast::Resource.new(:type => "file", :instances => ast::ASTArray.new(:children => [@instance]))
-     @resource.stubs(:qualified_type).returns("Resource")
-   end
+   describe "for builtin types" do
+     before :each do
+       @title = Puppet::Parser::AST::String.new(:value => "mytitle")
+       @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+       @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
+       @scope.stubs(:resource).returns(stub_everything)
 -      @resource = ast::Resource.new(:title => @title, :type => "file", :parameters => ast::ASTArray.new(:children => []) )
++      @instance = ast::ResourceInstance.new(:title => @title, :parameters => ast::ASTArray.new(:children => []))
++      @resource = ast::Resource.new(:type => "file", :instances => ast::ASTArray.new(:children => [@instance]))
+       @resource.stubs(:qualified_type).returns("Resource")
+     end
  
-   it "should evaluate all its parameters" do
-     param = stub 'param'
-     param.expects(:safeevaluate).with(@scope).returns Puppet::Parser::Resource::Param.new(:name => "myparam", :value => "myvalue", :source => stub("source"))
-     @instance.stubs(:parameters).returns [param]
+     it "should evaluate all its parameters" do
+       param = stub 'param'
+       param.expects(:safeevaluate).with(@scope).returns Puppet::Parser::Resource::Param.new(:name => "myparam", :value => "myvalue", :source => stub("source"))
 -      @resource.stubs(:parameters).returns [param]
++      @instance.stubs(:parameters).returns [param]
  
-     @resource.evaluate(@scope)
-   end
+       @resource.evaluate(@scope)
+     end
  
-   it "should evaluate its title" do
-     @resource.evaluate(@scope)[0].title.should == "mytitle"
-   end
+     it "should evaluate its title" do
+       @resource.evaluate(@scope)[0].title.should == "mytitle"
+     end
+ 
+     it "should flatten the titles array" do
+       titles = []
+       %w{one two}.each do |title|
+         titles << Puppet::Parser::AST::String.new(:value => title)
+       end
  
-   it "should flatten the titles array" do
-     titles = []
-     %w{one two}.each do |title|
-       titles << Puppet::Parser::AST::String.new(:value => title)
+       array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+ 
 -      @resource.title = array
++      @instance.title = array
+       result = @resource.evaluate(@scope).collect { |r| r.title }
+       result.should be_include("one")
+       result.should be_include("two")
      end
  
-     array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+     it "should create and return one resource objects per title" do
+       titles = []
+       %w{one two}.each do |title|
+         titles << Puppet::Parser::AST::String.new(:value => title)
+       end
  
-     @instance.title = array
-     result = @resource.evaluate(@scope).collect { |r| r.title }
-     result.should be_include("one")
-     result.should be_include("two")
-   end
+       array = Puppet::Parser::AST::ASTArray.new(:children => titles)
  
-   it "should create and return one resource objects per title" do
-     titles = []
-     %w{one two}.each do |title|
-       titles << Puppet::Parser::AST::String.new(:value => title)
 -      @resource.title = array
++      @instance.title = array
+       result = @resource.evaluate(@scope).collect { |r| r.title }
+       result.should be_include("one")
+       result.should be_include("two")
      end
  
-     array = Puppet::Parser::AST::ASTArray.new(:children => titles)
++    it "should implicitly iterate over instances" do
++      new_title = Puppet::Parser::AST::String.new(:value => "other_title")
++      new_instance = ast::ResourceInstance.new(:title => new_title, :parameters => ast::ASTArray.new(:children => []))
++      @resource.instances.push(new_instance)
++      @resource.evaluate(@scope).collect { |r| r.title }.should == ["mytitle", "other_title"]
++    end
 +
-     @instance.title = array
-     result = @resource.evaluate(@scope).collect { |r| r.title }
-     result.should be_include("one")
-     result.should be_include("two")
-   end
+     it "should handover resources to the compiler" do
+       titles = []
+       %w{one two}.each do |title|
+         titles << Puppet::Parser::AST::String.new(:value => title)
+       end
  
-   it "should implicitly iterate over instances" do
-     new_title = Puppet::Parser::AST::String.new(:value => "other_title")
-     new_instance = ast::ResourceInstance.new(:title => new_title, :parameters => ast::ASTArray.new(:children => []))
-     @resource.instances.push(new_instance)
-     @resource.evaluate(@scope).collect { |r| r.title }.should == ["mytitle", "other_title"]
-   end
+       array = Puppet::Parser::AST::ASTArray.new(:children => titles)
  
-   it "should handover resources to the compiler" do
-     titles = []
-     %w{one two}.each do |title|
-       titles << Puppet::Parser::AST::String.new(:value => title)
 -      @resource.title = array
++      @instance.title = array
+       result = @resource.evaluate(@scope)
+ 
+       result.each do |res|
+         @compiler.catalog.resource(res.ref).should be_instance_of(Puppet::Parser::Resource)
+       end
      end
  
-     array = Puppet::Parser::AST::ASTArray.new(:children => titles)
+     it "should generate virtual resources if it is virtual" do
+       @resource.virtual = true
+ 
+       result = @resource.evaluate(@scope)
+       result[0].should be_virtual
+     end
  
-     @instance.title = array
-     result = @resource.evaluate(@scope)
+     it "should generate virtual and exported resources if it is exported" do
+       @resource.exported = true
  
-     result.each do |res|
-       @compiler.catalog.resource(res.ref).should be_instance_of(Puppet::Parser::Resource)
+       result = @resource.evaluate(@scope)
+       result[0].should be_virtual
+       result[0].should be_exported
      end
-   end
-   it "should generate virtual resources if it is virtual" do
-     @resource.virtual = true
  
-     result = @resource.evaluate(@scope)
-     result[0].should be_virtual
-   end
+     # Related to #806, make sure resources always look up the full path to the resource.
+     describe "when generating qualified resources" do
+       before do
+         @scope = Puppet::Parser::Scope.new :compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+         @parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new)
 -        @parser.newdefine "one"
 -        @parser.newdefine "one::two"
 -        @parser.newdefine "three"
++        ["one", "one::two", "three"].each do |name|
++          @parser.environment.known_resource_types.add(Puppet::Resource::Type.new(:definition, name, {}))
++        end
+         @twoscope = @scope.newscope(:namespace => "one")
+         @twoscope.resource = @scope.resource
+       end
  
-   it "should generate virtual and exported resources if it is exported" do
-     @resource.exported = true
+       def resource(type, params = nil)
+         params ||= Puppet::Parser::AST::ASTArray.new(:children => [])
 -        Puppet::Parser::AST::Resource.new(:type => type, :title => Puppet::Parser::AST::String.new(:value => "myresource"), :parameters => params)
++        instance = Puppet::Parser::AST::ResourceInstance.new(
++                                                             :title => Puppet::Parser::AST::String.new(:value => "myresource"), :parameters => params)
++        Puppet::Parser::AST::Resource.new(:type => type,
++                                          :instances => Puppet::Parser::AST::ASTArray.new(:children => [instance]))
+       end
  
-     result = @resource.evaluate(@scope)
-     result[0].should be_virtual
-     result[0].should be_exported
-   end
+       it "should be able to generate resources with fully qualified type information" do
+         resource("two").evaluate(@twoscope)[0].type.should == "One::Two"
+       end
  
-   # Related to #806, make sure resources always look up the full path to the resource.
-   describe "when generating qualified resources" do
-     before do
-       @scope = Puppet::Parser::Scope.new :compiler => Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
-       @parser = Puppet::Parser::Parser.new(Puppet::Node::Environment.new)
-       ["one", "one::two", "three"].each do |name|
-         @parser.environment.known_resource_types.add(Puppet::Resource::Type.new(:definition, name, {}))
+       it "should be able to generate resources with unqualified type information" do
+         resource("one").evaluate(@twoscope)[0].type.should == "One"
        end
-       @twoscope = @scope.newscope(:namespace => "one")
-       @twoscope.resource = @scope.resource
-     end
  
-     def resource(type, params = nil)
-       params ||= Puppet::Parser::AST::ASTArray.new(:children => [])
-       instance = Puppet::Parser::AST::ResourceInstance.new(
-           :title => Puppet::Parser::AST::String.new(:value => "myresource"), :parameters => params)
-       Puppet::Parser::AST::Resource.new(:type => type,
-                                         :instances => Puppet::Parser::AST::ASTArray.new(:children => [instance]))
-     end
+       it "should correctly generate resources that can look up builtin types" do
+         resource("file").evaluate(@twoscope)[0].type.should == "File"
+       end
  
-     it "should be able to generate resources with fully qualified type information" do
-       resource("two").evaluate(@twoscope)[0].type.should == "One::Two"
-     end
+       it "should correctly generate resources that can look up defined classes by title" do
+         @scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
+         @scope.compiler.stubs(:evaluate_classes)
+         res = resource("class").evaluate(@twoscope)[0]
+         res.type.should == "Class"
+         res.title.should == "Myresource"
+       end
  
-     it "should be able to generate resources with unqualified type information" do
-       resource("one").evaluate(@twoscope)[0].type.should == "One"
+       it "should evaluate parameterized classes when they are instantiated" do
+         @scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
+         @scope.compiler.expects(:evaluate_classes).with(['myresource'], at twoscope,false)
+         resource("class").evaluate(@twoscope)[0]
+       end
+ 
+       it "should fail for resource types that do not exist" do
+         lambda { resource("nosuchtype").evaluate(@twoscope) }.should raise_error(Puppet::ParseError)
+       end
      end
+   end
  
-     it "should correctly generate resources that can look up builtin types" do
-       resource("file").evaluate(@twoscope)[0].type.should == "File"
+   describe "for class resources" do
+     before do
+       @title = Puppet::Parser::AST::String.new(:value => "classname")
+       @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("mynode"))
+       @scope = Puppet::Parser::Scope.new(:compiler => @compiler)
+       @scope.stubs(:resource).returns(stub_everything)
 -      @resource = ast::Resource.new(:title => @title, :type => "Class", :parameters => ast::ASTArray.new(:children => []) )
++      @instance = ast::ResourceInstance.new(:title => @title, :parameters => ast::ASTArray.new(:children => []))
++      @resource = ast::Resource.new(:type => "Class", :instances => ast::ASTArray.new(:children => [@instance]))
+       @resource.stubs(:qualified_type).returns("Resource")
+       @type = Puppet::Resource::Type.new(:hostclass, "classname")
+       @compiler.known_resource_types.add(@type)
      end
  
-     it "should correctly generate resources that can look up defined classes by title" do
-       @scope.known_resource_types.add_hostclass Puppet::Resource::Type.new(:hostclass, "Myresource", {})
-       res = resource("class").evaluate(@twoscope)[0]
-       res.type.should == "Class"
-       res.title.should == "Myresource"
+     it "should instantiate the class" do
+       @compiler.stubs(:evaluate_classes)
+       result = @resource.evaluate(@scope)
+       result.length.should == 1
+       result.first.ref.should == "Class[Classname]"
+       @compiler.catalog.resource("Class[Classname]").should equal result.first
      end
  
-     it "should fail for resource types that do not exist" do
-       lambda { resource("nosuchtype").evaluate(@twoscope) }.should raise_error(Puppet::ParseError)
+     it "should cause its parent to be evaluated" do
+       parent_type = Puppet::Resource::Type.new(:hostclass, "parentname")
+       @compiler.stubs(:evaluate_classes)
+       @compiler.known_resource_types.add(parent_type)
+       @type.parent = "parentname"
+       result = @resource.evaluate(@scope)
+       result.length.should == 1
+       result.first.ref.should == "Class[Classname]"
+       @compiler.catalog.resource("Class[Classname]").should equal result.first
+       @compiler.catalog.resource("Class[Parentname]").should be_instance_of(Puppet::Parser::Resource)
      end
+ 
    end
+ 
  end
diff --combined spec/unit/resource/type_spec.rb
index 7701e55,7b240bb..ef45712
--- a/spec/unit/resource/type_spec.rb
+++ b/spec/unit/resource/type_spec.rb
@@@ -322,7 -322,7 +322,7 @@@ describe Puppet::Resource::Type d
      end
  
      it "should set its module name in the scope if available" do
 -      @type.module_name = "mymod"
 +      @type.instance_eval { @module_name = "mymod" }
  
        @type.set_resource_parameters(@resource, @scope)
  
@@@ -531,7 -531,8 +531,7 @@@
          @compiler.add_resource @scope, @parent_resource
  
          @type.resource_type_collection = @scope.known_resource_types
 -        @type.resource_type_collection.stubs(:node).with("parent").returns(@parent_type)
 -        @type.resource_type_collection.stubs(:node).with("Parent").returns(@parent_type)
 +        @type.resource_type_collection.add(@parent_type)
        end
  
        it "should evaluate the parent's resource" do
@@@ -579,29 -580,29 +579,29 @@@
      end
  
      it "should create a resource instance" do
-       @top.mk_plain_resource(@scope).should be_instance_of(Puppet::Parser::Resource)
+       @top.ensure_in_catalog(@scope).should be_instance_of(Puppet::Parser::Resource)
      end
  
      it "should set its resource type to 'class' when it is a hostclass" do
-       Puppet::Resource::Type.new(:hostclass, "top").mk_plain_resource(@scope).type.should == "Class"
+       Puppet::Resource::Type.new(:hostclass, "top").ensure_in_catalog(@scope).type.should == "Class"
      end
  
      it "should set its resource type to 'node' when it is a node" do
-       Puppet::Resource::Type.new(:node, "top").mk_plain_resource(@scope).type.should == "Node"
+       Puppet::Resource::Type.new(:node, "top").ensure_in_catalog(@scope).type.should == "Node"
      end
  
      it "should fail when it is a definition" do
-       lambda { Puppet::Resource::Type.new(:definition, "top").mk_plain_resource(@scope) }.should raise_error(ArgumentError)
+       lambda { Puppet::Resource::Type.new(:definition, "top").ensure_in_catalog(@scope) }.should raise_error(ArgumentError)
      end
  
      it "should add the created resource to the scope's catalog" do
-       @top.mk_plain_resource(@scope)
+       @top.ensure_in_catalog(@scope)
  
        @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
      end
  
      it "should evaluate the parent class if one exists" do
-       @middle.mk_plain_resource(@scope)
+       @middle.ensure_in_catalog(@scope)
  
        @compiler.catalog.resource(:class, "top").should be_instance_of(Puppet::Parser::Resource)
      end
@@@ -609,40 -610,40 +609,40 @@@
      it "should fail to evaluate if a parent class is defined but cannot be found" do
        othertop = Puppet::Resource::Type.new :hostclass, "something", :parent => "yay"
        @code.add othertop
-       lambda { othertop.mk_plain_resource(@scope) }.should raise_error(Puppet::ParseError)
+       lambda { othertop.ensure_in_catalog(@scope) }.should raise_error(Puppet::ParseError)
      end
  
      it "should not create a new resource if one already exists" do
        @compiler.catalog.expects(:resource).with(:class, "top").returns("something")
        @compiler.catalog.expects(:add_resource).never
-       @top.mk_plain_resource(@scope)
+       @top.ensure_in_catalog(@scope)
      end
  
      it "should return the existing resource when not creating a new one" do
        @compiler.catalog.expects(:resource).with(:class, "top").returns("something")
        @compiler.catalog.expects(:add_resource).never
-       @top.mk_plain_resource(@scope).should == "something"
+       @top.ensure_in_catalog(@scope).should == "something"
      end
  
      it "should not create a new parent resource if one already exists and it has a parent class" do
-       @top.mk_plain_resource(@scope)
+       @top.ensure_in_catalog(@scope)
  
        top_resource = @compiler.catalog.resource(:class, "top")
  
-       @middle.mk_plain_resource(@scope)
+       @middle.ensure_in_catalog(@scope)
  
        @compiler.catalog.resource(:class, "top").should equal(top_resource)
      end
  
      # #795 - tag before evaluation.
      it "should tag the catalog with the resource tags when it is evaluated" do
-       @middle.mk_plain_resource(@scope)
+       @middle.ensure_in_catalog(@scope)
  
        @compiler.catalog.should be_tagged("middle")
      end
  
      it "should tag the catalog with the parent class tags when it is evaluated" do
-       @middle.mk_plain_resource(@scope)
+       @middle.ensure_in_catalog(@scope)
  
        @compiler.catalog.should be_tagged("top")
      end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list