projects
/
graph.njae.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Finished graph produce and similarity matching
[graph.njae.git]
/
spec
/
graph
/
vertex_spec.rb
diff --git
a/spec/graph/vertex_spec.rb
b/spec/graph/vertex_spec.rb
index 49ce58ccf92b6c234b9ce2a4264b4e6f4ece74c0..e091289557143377b6f5c7923e3f156b0350ebe0 100644
(file)
--- a/
spec/graph/vertex_spec.rb
+++ b/
spec/graph/vertex_spec.rb
@@
-9,6
+9,14
@@
module GraphNjae
v = Vertex.new
v.edges.should be_empty
end
v = Vertex.new
v.edges.should be_empty
end
+
+ it "creates a vertex with some parameters" do
+ v = Vertex.new :value1 => 1, :value2 => "value2", :value3 => :v3
+ v.value1.should == 1
+ v.value2.should == "value2"
+ v.value3.should == :v3
+ v.value4.should be_nil
+ end
end # #initialize
describe "adds attribues" do
end # #initialize
describe "adds attribues" do
@@
-77,9
+85,16
@@
module GraphNjae
e.vertices.should include(v)
e.vertices.should include(v1)
e.vertices.should include(v)
e.vertices.should include(v1)
-
e.should have(2).connections
+ e.should have(2).connections
end
end
+ it "connects two vertices by an edge with attributes" do
+ v1 = Vertex.new
+ v1.id = :v1
+ e = v.connect(v1, {:type => :edge_type})
+ e.type.should == :edge_type
+ end
+
it "creates a self-connection" do
e = v.connect v
it "creates a self-connection" do
e = v.connect v
@@
-96,6
+111,11
@@
module GraphNjae
e.should have(2).connections
end
e.should have(2).connections
end
+ it "creates a self-connection with an edge with attributes" do
+ e = v.connect(v, {:type => :edge_type})
+ e.type.should == :edge_type
+ end
+
end # #connect
describe "#neighbours" do
end # #connect
describe "#neighbours" do