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
12 it
"creates an edge with some parameters" do
13 e
= Edge
.new
:value1 => 1, :value2 => "value2", :value3 => :v3
15 e
.value2
.should
== "value2"
16 e
.value3
.should
== :v3
17 e
.value4
.should be_nil
22 describe
"adds attribues" do
23 it
"adds then reports arbitrary attributes" do
30 it
"adds a new vertex to an edge (with a connection)" do
31 e
.connections
.should be_empty
35 e
.should
have(1).connections
36 e
.should
have(1).vertices
37 e
.vertices
.should
include(v1
)
38 v1
.edges
.should
include(e
)
40 e
.should
have(2).connections
41 e
.should
have(2).vertices
42 e
.vertices
.should
include(v1
)
43 e
.vertices
.should
include(v2
)
44 v2
.edges
.should
include(e
)
47 it
"adds several vertices to an edge" do
48 e
.connections
.should be_empty
52 e
.vertices
.should
include(v1
)
53 e
.vertices
.should
include(v2
)
54 e
.should
have(2).vertices
57 it
"adds a self-loop" do
58 e
.connections
.should be_empty
61 e
.vertices
.should
include(v1
)
62 e
.should
have(2).vertices
63 e
.vertices
.uniq
.length
.should
== 1
67 describe
"connection_at" do
68 it
"returns the connection that links to a vertex" do
69 e
.connections
.should be_empty
74 e
.connection_at(v1
).end.should be v1
75 e
.connection_at(v2
).end.should be v2
78 it
"returns nil if there is no connection to that vertex" do
79 e
.connections
.should be_empty
85 e
.connection_at(v3
).should be
nil
88 it
"returns the vertex for a self-loop" do
89 e
.connections
.should be_empty
93 e
.connection_at(v1
).end.should be v1
100 describe Connection
do
101 let (:c) {Connection
.new
}
103 describe
"adds attribues" do
104 it
"adds then reports arbitrary attributes" do
108 end # adds attributes