Bug fix in Vertex#neighbours
[graph.njae.git] / spec / graph / graph_spec.rb
index ba7bea13cf1bcc87ddc3975736eb30f646e0223e..09cc6a433cddd36d28d78fa4c09fc9f2542450da 100644 (file)
@@ -1,6 +1,13 @@
 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
 
 module GraphNjae
+
+  class SVertex < Vertex
+  end
+  
+  class SEdge < Edge
+  end
+  
   describe Graph do
     let (:g) { Graph.new }
     describe "#initialize" do
@@ -54,6 +61,16 @@ module GraphNjae
         g.edges.should include(e1)
         g.edges.should include(e2)
       end
+      
+      it "adds a subclass of Vertex" do
+        g.vertices.should be_empty
+        v1 = SVertex.new
+        v2 = SVertex.new
+        g << v1 << v2
+        g.should have(2).vertices
+        g.vertices.should include(v1)
+        g.vertices.should include(v2)        
+      end
     end # #<<
 
     describe "connect" do