6 describe "#initialize" do
7 it "creates an empty edge" do
9 e.connections.should be_empty
13 describe "adds attribues" do
14 it "adds then reports arbitrary attributes" do
21 it "adds a new vertex to an edge (with a connection)" do
22 e.connections.should be_empty
26 e.should have(1).connections
27 e.should have(1).vertices
28 e.vertices.should include(v1)
30 e.should have(2).connections
31 e.should have(2).vertices
32 e.vertices.should include(v1)
33 e.vertices.should include(v2)
36 it "adds several vertices to an edge" do
37 e.connections.should be_empty
41 e.vertices.should include(v1)
42 e.vertices.should include(v2)
43 e.should have(2).vertices
46 it "adds a self-loop" do
47 e.connections.should be_empty
50 e.vertices.should include(v1)
51 e.should have(2).vertices
52 e.vertices.uniq.length.should == 1
56 describe "connection_at" do
57 it "returns the connection that links to a vertex" do
58 e.connections.should be_empty
63 e.connection_at(v1).end.should be v1
64 e.connection_at(v2).end.should be v2
67 it "returns nil if there is no connection to that vertex" do
68 e.connections.should be_empty
74 e.connection_at(v3).should be nil
79 describe Connection do
80 let (:c) {Connection.new }
82 describe "adds attribues" do
83 it "adds then reports arbitrary attributes" do