summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-03-10 04:07:12 -0500
committerLuke Kanies <luke@madstop.com>2009-03-10 04:07:12 -0500
commitf8dea989e3f5bd7d3d823a6c3dc3cf76cd5cba4e (patch)
tree29bbe8128203444ed2e47207c69d87601fb30c21 /spec/unit
parentd0fc2f5738a78c51128f6377c03fe42cf50371a0 (diff)
downloadpuppet-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')
-rwxr-xr-xspec/unit/relationship.rb61
-rwxr-xr-xspec/unit/simple_graph.rb10
2 files changed, 34 insertions, 37 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
diff --git a/spec/unit/simple_graph.rb b/spec/unit/simple_graph.rb
index a73e75a42..2c061ae1a 100755
--- a/spec/unit/simple_graph.rb
+++ b/spec/unit/simple_graph.rb
@@ -107,14 +107,14 @@ describe Puppet::SimpleGraph do
end
it "should provide a method to add an edge by specifying the two vertices and a label" do
- @graph.add_edge(:one, :two, :stuff => :awesome)
+ @graph.add_edge(:one, :two, :callback => :awesome)
@graph.edge?(:one, :two).should be_true
end
it "should provide a method for retrieving an edge label" do
- edge = Puppet::Relationship.new(:one, :two, :stuff => :awesome)
+ edge = Puppet::Relationship.new(:one, :two, :callback => :awesome)
@graph.add_edge(edge)
- @graph.edge_label(:one, :two).should == {:stuff => :awesome}
+ @graph.edge_label(:one, :two).should == {:callback => :awesome}
end
it "should provide a method for retrieving an edge" do
@@ -236,9 +236,9 @@ describe Puppet::SimpleGraph do
end
it "should retain labels on edges" do
- @graph.add_edge(:one, :two, :stuff => :awesome)
+ @graph.add_edge(:one, :two, :callback => :awesome)
edge = @graph.reversal.edge(:two, :one)
- edge.label.should == {:stuff => :awesome}
+ edge.label.should == {:callback => :awesome}
end
end