2e7dbfcc9a64863648ed928699155ea173c004b0
1 require File
.expand_path(File
.dirname(__FILE__
) + '/../spec_helper')
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
77 it
"returns the vertex for a self-loop" do
78 e
.connections
.should be_empty
82 e
.connection_at(v1
).end.should be v1
89 describe Connection
do
90 let (:c) {Connection
.new
}
92 describe
"adds attribues" do
93 it
"adds then reports arbitrary attributes" do