diff options
author | Luke Kanies <luke@madstop.com> | 2007-09-12 18:40:54 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-09-12 18:40:54 -0500 |
commit | 3632926089cb27b93ff075c05ba21e2340a562ac (patch) | |
tree | 358905669eec4eef70e1f7997c35f3ecec82c1f5 /spec/unit | |
parent | 43f22a2414048b180d2c0e2a421fa8d905c4d8eb (diff) | |
download | puppet-3632926089cb27b93ff075c05ba21e2340a562ac.tar.gz puppet-3632926089cb27b93ff075c05ba21e2340a562ac.tar.xz puppet-3632926089cb27b93ff075c05ba21e2340a562ac.zip |
Moving the resource container behaviour to the Configuration object, rather than the base PGraph class. I expect I will just do away with PGraph, but for now, I am at least going to keep configuration-related code in that class.
Diffstat (limited to 'spec/unit')
-rwxr-xr-x | spec/unit/node/configuration.rb | 23 | ||||
-rwxr-xr-x | spec/unit/other/pgraph.rb | 25 |
2 files changed, 23 insertions, 25 deletions
diff --git a/spec/unit/node/configuration.rb b/spec/unit/node/configuration.rb index 4429fe3a3..774a1550f 100755 --- a/spec/unit/node/configuration.rb +++ b/spec/unit/node/configuration.rb @@ -133,3 +133,26 @@ describe Puppet::Node::Configuration, " when extracting transobjects" do botarray.include?(:botres).should be_true end end + +describe Puppet::Node::Configuration, " functioning as a resource container" do + before do + @graph = Puppet::Node::Configuration.new("host") + @one = stub 'resource1', :ref => "Me[you]" + @two = stub 'resource2', :ref => "Me[him]" + @dupe = stub 'resource3', :ref => "Me[you]" + end + + it "should make all vertices available by resource reference" do + @graph.add_resource(@one) + @graph.resource(@one.ref).should equal(@one) + end + + it "should not allow two resources with the same resource reference" do + @graph.add_resource(@one) + proc { @graph.add_resource(@dupe) }.should raise_error(ArgumentError) + end + + it "should not store objects that do not respond to :ref" do + proc { @graph.add_resource("thing") }.should raise_error(ArgumentError) + end +end diff --git a/spec/unit/other/pgraph.rb b/spec/unit/other/pgraph.rb index d4af87ba0..19809ac1e 100755 --- a/spec/unit/other/pgraph.rb +++ b/spec/unit/other/pgraph.rb @@ -283,28 +283,3 @@ describe Puppet::PGraph, " when sorting the graph" do proc { @graph.topsort }.should_not raise_error end end - -describe Puppet::PGraph, " functioning as a resource container" do - before do - @graph = Puppet::PGraph.new - @one = stub 'resource1', :ref => "Me[you]" - @two = stub 'resource2', :ref => "Me[him]" - @dupe = stub 'resource3', :ref => "Me[you]" - end - - it "should make all vertices available by resource reference" do - @graph.add_vertex!(@one) - @graph.resource(@one.ref).should equal(@one) - end - - it "should not allow two resources with the same resource reference" do - @graph.add_vertex!(@one) - proc { @graph.add_vertex!(@dupe) }.should raise_error(ArgumentError) - end - - it "should not store objects that do not respond to :ref" do - str = "thing" - @graph.add_vertex!(str) - @graph.resource(str).should be_nil - end -end |