diff options
| author | Luke Kanies <luke@madstop.com> | 2008-12-11 12:31:01 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-12-18 11:10:23 -0600 |
| commit | fae30756e48184dfc8238dcfe80b843f981b6070 (patch) | |
| tree | 9de8d66a6cd9a73b720786a25843e837048ec628 /spec | |
| parent | 14c3c54ee1976e1c76acfe62554bb1786da6427b (diff) | |
Simplifying the initialization interface for References
You previously had to call new(nil, "Foo[bar]") if you
just had the resource reference as a string. Now
you can call new("Foo[bar]"), but the old behaviour
works, too.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/resource/reference.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/resource/reference.rb b/spec/unit/resource/reference.rb index 001aa0395..fa2d87bd5 100755 --- a/spec/unit/resource/reference.rb +++ b/spec/unit/resource/reference.rb @@ -47,6 +47,16 @@ describe Puppet::Resource::Reference do ref.title.should =="baz[yay]" end + it "should interpret the type as a reference and assign appropriately if the title is nil and the type contains square brackets" do + ref = Puppet::Resource::Reference.new("foo::bar[baz]") + ref.type.should == "Foo::Bar" + ref.title.should =="baz" + end + + it "should fail if the title is nil and the type is not a valid resource reference string" do + lambda { Puppet::Resource::Reference.new("foo") }.should raise_error(ArgumentError) + end + it "should be considered builtin if an existing resource type matches the type" do Puppet::Resource::Reference.new("file", "/f").should be_builtin_type end |
