X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=spec%2Ferd_handler%2Ferd_spec.rb;h=12ef23972e4674b8580e2b03eb6cb40c69797243;hb=54fb8d2f752d1ad35d11a03bb6e1443257a472c9;hp=ec75afeb416448d92dd0f0fba9f584384592ee0a;hpb=29a64f0a2207a69d136c6f67edcd6855af8152d8;p=erd-marker.git diff --git a/spec/erd_handler/erd_spec.rb b/spec/erd_handler/erd_spec.rb index ec75afe..12ef239 100644 --- a/spec/erd_handler/erd_spec.rb +++ b/spec/erd_handler/erd_spec.rb @@ -1,19 +1,37 @@ require 'spec_helper' -module Erd +module ErdHandler describe Erd do let(:input) { double('input').as_null_object } let(:output) { double('output').as_null_object } let(:erd) { Erd.new(input, output) } - describe "#read" do - it "reads a single box" do - doc = Document.new File.new("spec/fixtures/single_box_erd.xml") - erd = Erd.new doc - erd.mark.should == 6.5 - erd.boxes.length.should == 1 - + describe "#initialize" do + it "creates an empty ERD" do + erd = Erd.new + erd.mark.should be_nil + erd.should have(0).vertices + erd.should have(0).edges end - end # #read + + it "reads and creates a single box" do + erd = Erd.new(File.new("spec/fixtures/single_box_erd.xml")) + erd.mark.should == 6.5 + erd.should have(1).vertices + erd.should have(0).edges + end + + it "reads and creates two boxes with an edge joining them" do + erd = Erd.new(File.new("spec/fixtures/two_boxes_one_link_erd.xml")) + erd.mark.should == 4.5 + erd.should have(2).vertices + erd.should have(1).edges + + erd.vertices[0].neighbours.should include(erd.vertices[1]) + erd.vertices[1].neighbours.should include(erd.vertices[0]) + end + + it "reads and creates a box with a self-loop" + end # #initialize end -end \ No newline at end of file +end