summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/resource/reference.rb4
-rwxr-xr-xspec/unit/parser/resource.rb11
-rwxr-xr-xspec/unit/parser/resource/reference.rb7
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/puppet/resource/reference.rb b/lib/puppet/resource/reference.rb
index dce4449de..eddb2d96b 100644
--- a/lib/puppet/resource/reference.rb
+++ b/lib/puppet/resource/reference.rb
@@ -50,6 +50,10 @@ class Puppet::Resource::Reference
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
x = @type = value.to_s.split("::").collect { |s| s.capitalize }.join("::")
end
+
+ if @title
+ self.title = @title
+ end
end
# Convert to the reference format that TransObject uses. Yay backward
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 3f08de958..d41d4f48b 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -101,6 +101,17 @@ describe Puppet::Parser::Resource do
end
end
+ describe "when refering to a resource with name canonicalization" do
+ before do
+ @arguments = {:type => "file", :title => "/path/", :scope => stub('scope', :source => mock('source'))}
+ end
+
+ it "should canonicalize its own name" do
+ res = Puppet::Parser::Resource.new(@arguments)
+ res.ref.should == "File[/path]"
+ end
+ end
+
describe "when evaluating" do
before do
@type = Puppet::Parser::Resource
diff --git a/spec/unit/parser/resource/reference.rb b/spec/unit/parser/resource/reference.rb
index a703f9284..19fe076e5 100755
--- a/spec/unit/parser/resource/reference.rb
+++ b/spec/unit/parser/resource/reference.rb
@@ -49,6 +49,13 @@ describe Puppet::Parser::Resource::Reference do
ref = @type.new(:type => "file", :title => "/tmp/yay/")
ref.to_s.should == "File[/tmp/yay]"
end
+
+ it "should canonize resource reference values without order dependencies" do
+ args = [[:title, "/tmp/yay/"], [:type, "file"]]
+ ref = @type.new(args)
+ ref.to_s.should == "File[/tmp/yay]"
+ end
+
end
describe Puppet::Parser::Resource::Reference, " when modeling defined types" do