Sha256: 42a29330b2d1500f8e96d0475e332ee2de7aa885f95f18d17fbc2f2a75d4d974

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

require "spec_helper"
require "graphshaper/adapters/logging_adapter"

describe Graphshaper::LoggingAdapter do
  before :each do
    @vertex_logger = double()
    @vertex_logger.stub :<<
    @edge_logger = double()
    @edge_logger.stub :<<
  end
  
  it "should write a header into the files" do
    @vertex_logger.should_receive(:<<).with("vertex_id\n")
    @edge_logger.should_receive(:<<).with("edge_id,from_id,to_id\n")
    Graphshaper::LoggingAdapter.new @vertex_logger, @edge_logger
  end
  
  describe "Initialized Logger" do
    before :each do
      @adapter = Graphshaper::LoggingAdapter.new @vertex_logger, @edge_logger
    end
    
    it "should write edges to the logger at edge creation" do
      @edge_logger.should_receive(:<<).with("0,1,3\n")
      @adapter.add_edge 0,1,3
    end
    
    it "should write vertices to the logger at vertex creation" do
      @vertex_logger.should_receive(:<<).with("5\n")
      @adapter.add_vertex 5
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphshaper-0.2.4 spec/adapters/logging_adapter_spec.rb
graphshaper-0.2.3 spec/adapters/logging_adapter_spec.rb