Sha256: 55a4da6dad47bf42f2c7216c867c6371b493b39a1ed9a091345ea7c0c5be3b01

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

require "spec_helper"

describe Graphshaper::DotAdapter do
  before :each do
    @output_file = double()
    @output_file.stub :<<
  end
  
  it "should write a header into the file" do
    @output_file.should_receive(:<<).with("digraph genereated_graph { \n  rankdir=LR;\n  node [shape = circle];\n  edge [dir=none];\n")
    Graphshaper::DotAdapter.new @output_file
  end
  
  describe "initialized Dot Adapter" do
    before :each do
      @dot_adapter = Graphshaper::DotAdapter.new @output_file
    end
    
    it "should be closeable" do
      @output_file.should_receive(:<<).with("}")
      @dot_adapter.close
    end
    
    it "should write an edge in the correct format" do
      @output_file.should_receive(:<<).with("  1 -> 2 [ label = \"0\" ];\n")
      @dot_adapter.add_edge(0,1,2)
    end
    
    it "should write a vertex in the correct format" do
      @output_file.should_receive(:<<).with("  15;\n")
      @dot_adapter.add_vertex(15)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
graphshaper-0.2.2 spec/adapters/dot_adapter_spec.rb