X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;ds=sidebyside;f=spec%2Fgraph%2Fgraph_spec.rb;fp=spec%2Fgraph%2Fgraph_spec.rb;h=7227a6f8e1abdf60b25efe5bc419ca2c8a861ba4;hb=624e339a169bd96eb01da7288a8904e0d1830e42;hp=0000000000000000000000000000000000000000;hpb=7f38e9910061e8a71db6dac57327ca1f5d3c27cd;p=graph.njae.git

diff --git a/spec/graph/graph_spec.rb b/spec/graph/graph_spec.rb
new file mode 100644
index 0000000..7227a6f
--- /dev/null
+++ b/spec/graph/graph_spec.rb
@@ -0,0 +1,65 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+module Graph
+  describe Graph do
+    let (:g) { Graph.new }
+    describe "#initialize" do
+      it "creates an empty graph" do
+        g = Graph.new
+        g.edges.should be_empty
+        g.vertices.should be_empty
+      end
+    end # #initialize
+      
+    describe "adds attribues" do
+      it "adds then reports arbitrary attributes" do
+        g.score = 15
+        g.score == 15
+      end
+    end # adds attributes
+    
+    describe "#<<" do
+      it "adds a set of vertices" do
+        g.vertices.should be_empty
+        v1 = Vertex.new
+        v2 = Vertex.new
+        g << v1 << v2
+        g.should have(2).vertices
+        g.vertices.should include(v1)
+        g.vertices.should include(v2)
+      end
+      
+      it "adds a set of edges" do
+        g.edges.should be_empty
+        e1 = Edge.new
+        e2 = Edge.new
+        g << e1 << e2
+        g.should have(2).edges
+        g.edges.should include(e1)
+        g.edges.should include(e2)
+      end
+      
+      it "adds a mixed set of vertices and edges" do
+        g.vertices.should be_empty
+        g.edges.should be_empty
+        v1 = Vertex.new
+        v2 = Vertex.new
+        e1 = Edge.new
+        e2 = Edge.new
+        g << v1 << e1 << v2 << e2
+        g.should have(2).vertices
+        g.vertices.should include(v1)
+        g.vertices.should include(v2)
+        g.should have(2).edges
+        g.edges.should include(e1)
+        g.edges.should include(e2)
+      end
+    end # #<<
+
+    describe "connect" do
+      it "adds and records an edge between vertices" do
+      end
+    end # #connect
+    
+  end
+end