diff options
author | Luke Kanies <luke@madstop.com> | 2009-03-10 04:07:12 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2009-03-10 04:07:12 -0500 |
commit | f8dea989e3f5bd7d3d823a6c3dc3cf76cd5cba4e (patch) | |
tree | 29bbe8128203444ed2e47207c69d87601fb30c21 /spec/unit/relationship.rb | |
parent | d0fc2f5738a78c51128f6377c03fe42cf50371a0 (diff) | |
download | puppet-f8dea989e3f5bd7d3d823a6c3dc3cf76cd5cba4e.tar.gz puppet-f8dea989e3f5bd7d3d823a6c3dc3cf76cd5cba4e.tar.xz puppet-f8dea989e3f5bd7d3d823a6c3dc3cf76cd5cba4e.zip |
Fixing #1949 - relationships now use attributes instead of a label
This was important because the use of the label to store attributes
was a holdover from the GRATR library, and if we didn't cease its
use before we switched to RESTful catalogs, then we'd be stuck with
the @label instance variable forever, essentially.
Now we can add and remove variables however we please.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/relationship.rb')
-rwxr-xr-x | spec/unit/relationship.rb | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/spec/unit/relationship.rb b/spec/unit/relationship.rb index 5f96cdf8c..4d1b75856 100755 --- a/spec/unit/relationship.rb +++ b/spec/unit/relationship.rb @@ -19,61 +19,58 @@ describe Puppet::Relationship do @edge.should respond_to(:target) end - it "should have a :label attribute" do - @edge.should respond_to(:label) + it "should have a :callback attribute" do + @edge.callback = :foo + @edge.callback.should == :foo end - it "should provide a :ref method that describes the edge" do - @edge = Puppet::Relationship.new("a", "b") - @edge.ref.should == "a => b" + it "should have an :event attribute" do + @edge.event = :NONE + @edge.event.should == :NONE end -end -describe Puppet::Relationship, " when initializing" do - before do - @edge = Puppet::Relationship.new(:a, :b, :testing => :foo) + it "should require a callback if a non-NONE event is specified" do + proc { @edge.event = :something }.should raise_error(ArgumentError) end - it "should use the first argument as the source" do - @edge.source.should == :a + it "should have a :label attribute" do + @edge.should respond_to(:label) end - it "should use the second argument as the target" do - @edge.target.should == :b + it "should provide a :ref method that describes the edge" do + @edge = Puppet::Relationship.new("a", "b") + @edge.ref.should == "a => b" end - it "should use the third argument as the label" do - @edge.label.should == {:testing => :foo} - end + it "should be able to produce a label as a hash with its event and callback" do + @edge.callback = :foo + @edge.event = :bar - it "should require a callback if a non-NONE event is specified" do - proc { Puppet::Relationship.new(:a, :b, :event => :something) }.should raise_error(ArgumentError) + @edge.label.should == {:callback => :foo, :event => :bar} end - it "should require the label to be a hash" do - proc { Puppet::Relationship.new(:a, :b, :event) }.should raise_error(ArgumentError) + it "should work if nil options are provided" do + lambda { Puppet::Relationship.new("a", "b", nil) }.should_not raise_error end end -describe Puppet::Relationship, " when interpreting the label" do - it "should default to an event of nil" do +describe Puppet::Relationship, " when initializing" do + before do @edge = Puppet::Relationship.new(:a, :b) - @edge.event.should be_nil end - it "should expose a provided event via the :event method" do - @edge = Puppet::Relationship.new(:a, :b, :event => :something, :callback => :whatever) - @edge.event.should == :something + it "should use the first argument as the source" do + @edge.source.should == :a end - it "should default to a nil callback" do - @edge = Puppet::Relationship.new(:a, :b) - @edge.callback.should be_nil + it "should use the second argument as the target" do + @edge.target.should == :b end - it "should expose a provided callback via the :callback method" do - @edge = Puppet::Relationship.new(:a, :b, :callback => :testing) - @edge.callback.should == :testing + it "should set the rest of the arguments as the event and callback" do + @edge = Puppet::Relationship.new(:a, :b, :callback => :foo, :event => :bar) + @edge.callback.should == :foo + @edge.event.should == :bar end end |