summaryrefslogtreecommitdiffstats
path: root/spec/unit/resource_reference.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-11-28 15:20:52 -0600
committerLuke Kanies <luke@madstop.com>2007-11-28 15:20:52 -0600
commit11ae473e3852adcc382a3efea2329586d2e4bcb3 (patch)
tree7a7ff70f7d9f7bc9af0635c56690fb9fc810b9f5 /spec/unit/resource_reference.rb
parent8127397e1efafc13975b79eabf7ce951c1e90114 (diff)
downloadpuppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.gz
puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.tar.xz
puppet-11ae473e3852adcc382a3efea2329586d2e4bcb3.zip
Theoretically, this patch is to fix #917 (which it does), but
there were enough problems fixing it that I decided something more drastic needed to be done. This uses the new Puppet::ResourceReference class to canonize what a resource reference looks like and how to retrieve resources via their references. Specifically, it guarantees that resource types are always capitalized, even when they include '::' in them. While many files are modified in this commit, the majority of changes are quite small, and most of the changes are fixing the tests to use capitalized types. As we look at consolidating some of our resource types, we could consolidate the ResourceReference stuff at the same time, but at least the Puppet::Parser::ResourceReference class subclasses the main Puppet::ResourceReference class.
Diffstat (limited to 'spec/unit/resource_reference.rb')
-rwxr-xr-xspec/unit/resource_reference.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/unit/resource_reference.rb b/spec/unit/resource_reference.rb
index dad33866c..93eeaa5b8 100755
--- a/spec/unit/resource_reference.rb
+++ b/spec/unit/resource_reference.rb
@@ -16,6 +16,30 @@ describe Puppet::ResourceReference do
it "should canonize qualified types so all strings are capitalized" do
Puppet::ResourceReference.new("foo::bar", "foo").type.should == "Foo::Bar"
end
+
+ it "should set its type to 'Class' and its title to the passed title if the passed type is :component and the title has no square brackets in it" do
+ ref = Puppet::ResourceReference.new(:component, "foo")
+ ref.type.should == "Class"
+ ref.title.should == "foo"
+ end
+
+ it "should interpret the title as a reference and assign appropriately if the type is :component and the title contains square brackets" do
+ ref = Puppet::ResourceReference.new(:component, "foo::bar[yay]")
+ ref.type.should == "Foo::Bar"
+ ref.title.should == "yay"
+ end
+
+ it "should set the type to 'Class' if it is nil and the title contains no square brackets" do
+ ref = Puppet::ResourceReference.new(nil, "yay")
+ ref.type.should == "Class"
+ ref.title.should == "yay"
+ end
+
+ it "should interpret the title as a reference and assign appropriately if the type is nil and the title contains square brackets" do
+ ref = Puppet::ResourceReference.new(nil, "foo::bar[yay]")
+ ref.type.should == "Foo::Bar"
+ ref.title.should == "yay"
+ end
end
describe Puppet::ResourceReference, "when resolving resources without a configuration" do