diff options
| author | Markus Roberts <Markus@reality.com> | 2010-01-08 17:22:49 -0800 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | aab2374378e0db03e4657e327460406bc31da2c2 (patch) | |
| tree | 695c6325f9a6f5d7d9a922614347a9d2a8701613 | |
| parent | 86cf226916f793277e2405711993d7ccbc4e7965 (diff) | |
| download | puppet-aab2374378e0db03e4657e327460406bc31da2c2.tar.gz puppet-aab2374378e0db03e4657e327460406bc31da2c2.tar.xz puppet-aab2374378e0db03e4657e327460406bc31da2c2.zip | |
Resolving conflicts with luke:tickets/testing/2954
| -rw-r--r-- | lib/puppet/dsl/resource_api.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/dsl/resource_api.rb | 22 |
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/puppet/dsl/resource_api.rb b/lib/puppet/dsl/resource_api.rb index bac26d38a..98e52158b 100644 --- a/lib/puppet/dsl/resource_api.rb +++ b/lib/puppet/dsl/resource_api.rb @@ -53,7 +53,7 @@ class Puppet::DSL::ResourceAPI raise ArgumentError, "Resource arguments must be provided as a hash" unless arguments.is_a?(Hash) names.collect do |name| - resource = Puppet::Parser::Resource.new(:type => type, :title => name, :scope => scope) + resource = Puppet::Parser::Resource.new(type, name, :scope => scope) arguments.each do |param, value| resource[param] = value end diff --git a/spec/unit/dsl/resource_api.rb b/spec/unit/dsl/resource_api.rb index ddfc4e4b8..628e8c8ae 100755 --- a/spec/unit/dsl/resource_api.rb +++ b/spec/unit/dsl/resource_api.rb @@ -6,9 +6,9 @@ require 'puppet/dsl/resource_api' describe Puppet::DSL::ResourceAPI do before do - @compiler = stub 'compiler', :add_resource => nil - @scope = stub 'scope', :source => stub("source"), :compiler => @compiler - @resource = Puppet::Parser::Resource.new(:type => :mytype, :title => "myresource", :scope => @scope) + @compiler = Puppet::Parser::Compiler.new(Puppet::Node.new("foo")) + @scope = Puppet::Parser::Scope.new(:compiler => @compiler, :source => "foo") + @resource = Puppet::Parser::Resource.new(:mytype, "myresource", :scope => @scope) @api = Puppet::DSL::ResourceAPI.new(@resource, @scope, proc { }) end @@ -85,29 +85,29 @@ describe Puppet::DSL::ResourceAPI do describe "when creating a resource" do before do @api.scope.stubs(:source).returns stub("source") - @api.scope.stubs(:compiler).returns stub("compiler", :add_resource => nil) - @created_resource = Puppet::Parser::Resource.new(:title => "eh", :type => 'yay', :scope => @api.scope) + @api.scope.compiler.stubs(:add_resource) + @created_resource = Puppet::Parser::Resource.new("yay", "eh", :scope => @api.scope) end it "should create and return a resource of the type specified" do - Puppet::Parser::Resource.expects(:new).with { |args| args[:type] == "mytype" }.returns @created_resource + Puppet::Parser::Resource.expects(:new).with { |type, title, args| type == "mytype" }.returns @created_resource @api.create_resource("mytype", "myname", {:foo => "bar"}).should == [@created_resource] end it "should use the name from the first element of the provided argument array" do - Puppet::Parser::Resource.expects(:new).with { |args| args[:title] == "myname" }.returns @created_resource + Puppet::Parser::Resource.expects(:new).with { |type, title, args| title == "myname" }.returns @created_resource @api.create_resource("mytype", "myname", {:foo => "bar"}) end it "should create multiple resources if the first element of the argument array is an array" do - second_resource = Puppet::Parser::Resource.new(:title => "eh", :type => 'yay', :scope => @api.scope) - Puppet::Parser::Resource.expects(:new).with { |args| args[:title] == "first" }.returns @created_resource - Puppet::Parser::Resource.expects(:new).with { |args| args[:title] == "second" }.returns @created_resource + second_resource = Puppet::Parser::Resource.new('yay', "eh", :scope => @api.scope) + Puppet::Parser::Resource.expects(:new).with { |type, title, args| title == "first" }.returns @created_resource + Puppet::Parser::Resource.expects(:new).with { |type, title, args| title == "second" }.returns @created_resource @api.create_resource("mytype", ["first", "second"], {:foo => "bar"}) end it "should provide its scope as the scope" do - Puppet::Parser::Resource.expects(:new).with { |args| args[:scope] == @api.scope }.returns @created_resource + Puppet::Parser::Resource.expects(:new).with { |type, title, args| args[:scope] == @api.scope }.returns @created_resource @api.create_resource("mytype", "myname", {:foo => "bar"}) end |
