12ef23972e4674b8580e2b03eb6cb40c69797243
[erd-marker.git] / erd_spec.rb
1 require 'spec_helper'
2
3 module ErdHandler
4 describe Erd do
5 let(:input) { double('input').as_null_object }
6 let(:output) { double('output').as_null_object }
7 let(:erd) { Erd.new(input, output) }
8
9 describe "#initialize" do
10 it "creates an empty ERD" do
11 erd = Erd.new
12 erd.mark.should be_nil
13 erd.should have(0).vertices
14 erd.should have(0).edges
15 end
16
17 it "reads and creates a single box" do
18 erd = Erd.new(File.new("spec/fixtures/single_box_erd.xml"))
19 erd.mark.should == 6.5
20 erd.should have(1).vertices
21 erd.should have(0).edges
22 end
23
24 it "reads and creates two boxes with an edge joining them" do
25 erd = Erd.new(File.new("spec/fixtures/two_boxes_one_link_erd.xml"))
26 erd.mark.should == 4.5
27 erd.should have(2).vertices
28 erd.should have(1).edges
29
30 erd.vertices[0].neighbours.should include(erd.vertices[1])
31 erd.vertices[1].neighbours.should include(erd.vertices[0])
32 end
33
34 it "reads and creates a box with a self-loop"
35 end # #initialize
36 end
37 end