637499be06814ffaee4d1a6db7247282378579b0
1 require File
.expand_path(File
.dirname(__FILE__
) + '/../spec_helper')
5 let (:v) { Vertex
.new
}
7 describe
"#initialize" do
8 it
"creates an empty vertex" do
10 v
.edges
.should be_empty
14 describe
"adds attribues" do
15 it
"adds then reports arbitrary attributes" do
22 it
"adds a single edge between vertices" do
23 v
.neighbours
.should be_empty
24 v
.edges
.should be_empty
29 v1
.id
= :v1 # Need this to ensure that v != v1
31 v
.should
have(1).edges
32 v1
.should
have(1).edges
34 v1
.edges
.should
include(e
)
36 v
.should
have(1).neighbours
37 v
.neighbours
.should
include(v1
)
38 v
.neighbours
.should_not
include(v
)
39 v1
.should
have(1).neighbours
40 v1
.neighbours
.should
include(v
)
41 v1
.neighbours
.should_not
include(v1
)
44 it
"adds a single edge as a self-loop" do
45 v
.neighbours
.should be_empty
46 v
.edges
.should be_empty
50 v
.should
have(1).edges
51 v
.should
have(1).neighbours
52 v
.neighbours
.should
include(v
)
57 it
"connects two vertices" do
59 v1
.id
= :v1 # Need this to ensure that v != v1
63 v
.should
have(1).neighbours
64 v
.neighbours
.should
include(v1
)
65 v
.neighbours
.should_not
include(v
)
67 v1
.should
have(1).neighbours
68 v1
.neighbours
.should
include(v
)
69 v1
.neighbours
.should_not
include(v1
)
71 v
.should
have(1).edges
72 v
.edges
.should
include(e
)
73 v1
.should
have(1).edges
74 v1
.edges
.should
include(e
)
76 e
.should
have(2).vertices
77 e
.vertices
.should
include(v
)
78 e
.vertices
.should
include(v1
)
80 e
.should
have(2).connections
83 it
"creates a self-connection" do
86 v
.should
have(1).neighbours
87 v
.neighbours
.should
include(v
)
89 v
.should
have(1).edges
90 v
.edges
.should
include(e
)
92 e
.should
have(2).vertices
93 e
.vertices
.uniq
.length
.should
== 1
94 e
.vertices
.should
include(v
)
96 e
.should
have(2).connections