Sha256: 919119c4690766483557bd92acf498117f04ab335e41e9509c188163f745fe37

Contents?: true

Size: 546 Bytes

Versions: 2

Compression:

Stored size: 546 Bytes

Contents

require 'spec_helper'

describe Kruskal::JsonIO do
  it 'reads JSON in lines, outputs Ruby objects' do
    input = StringIO.new("[1, 2]\n[3, 4]\n[5, 6]")
    reader = Kruskal::JsonIO.new(input)
    objects = reader.map { |it| it }
    expect(objects.size).to eq 3
    expect(objects.first).to eq [1, 2]
    expect(objects.last).to eq [5, 6]
  end

  it 'writes object as JSON' do
    output = StringIO.new
    writer = Kruskal::JsonIO.new(output)
    writer << [1, 2]
    writer << [3, 4]
    expect(output.string).to eq "[1,2]\n[3,4]"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kruskal-0.1.1 spec/lib/kruskal/json_io_spec.rb
kruskal-0.1.0 spec/lib/kruskal/json_io_spec.rb