d139667126886b8c382368378ab1c43aafe44fc5
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
)
39 e
.should
have(2).connections
40 e
.should
have(2).vertices
41 e
.vertices
.should
include(v1
)
42 e
.vertices
.should
include(v2
)
45 it
"adds several vertices to an edge" do
46 e
.connections
.should be_empty
50 e
.vertices
.should
include(v1
)
51 e
.vertices
.should
include(v2
)
52 e
.should
have(2).vertices
55 it
"adds a self-loop" do
56 e
.connections
.should be_empty
59 e
.vertices
.should
include(v1
)
60 e
.should
have(2).vertices
61 e
.vertices
.uniq
.length
.should
== 1
65 describe
"connection_at" do
66 it
"returns the connection that links to a vertex" do
67 e
.connections
.should be_empty
72 e
.connection_at(v1
).end.should be v1
73 e
.connection_at(v2
).end.should be v2
76 it
"returns nil if there is no connection to that vertex" do
77 e
.connections
.should be_empty
83 e
.connection_at(v3
).should be
nil
86 it
"returns the vertex for a self-loop" do
87 e
.connections
.should be_empty
91 e
.connection_at(v1
).end.should be v1
98 describe Connection
do
99 let (:c) {Connection
.new
}
101 describe
"adds attribues" do
102 it
"adds then reports arbitrary attributes" do
106 end # adds attributes