Sha256: d2ac1b26e7d17f4d7f18193d2909dd5524bcab771b40cee8a9c6a87506aab62d

Contents?: true

Size: 855 Bytes

Versions: 9

Compression:

Stored size: 855 Bytes

Contents

require_relative 'test_helper'

class RowReaderTest < Minitest::Test
  describe IOStreams::Row::Reader do
    let :file_name do
      File.join(File.dirname(__FILE__), 'files', 'test.csv')
    end

    let :expected do
      CSV.read(file_name)
    end

    describe '.open' do
      it 'file' do
        rows  = []
        count = IOStreams::Row::Reader.file(file_name) do |io|
          io.each { |row| rows << row }
        end
        assert_equal expected, rows
        assert_equal expected.size, count
      end

      it 'stream' do
        rows  = []
        count = IOStreams::Line::Reader.file(file_name) do |file|
          IOStreams::Row::Reader.stream(file) do |io|
            io.each { |row| rows << row }
          end
        end
        assert_equal expected, rows
        assert_equal expected.size, count
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-1.1.0 test/row_reader_test.rb
iostreams-1.0.0 test/row_reader_test.rb
iostreams-1.0.0.beta7 test/row_reader_test.rb
iostreams-1.0.0.beta6 test/row_reader_test.rb
iostreams-1.0.0.beta5 test/row_reader_test.rb
iostreams-1.0.0.beta4 test/row_reader_test.rb
iostreams-1.0.0.beta3 test/row_reader_test.rb
iostreams-1.0.0.beta2 test/row_reader_test.rb
iostreams-1.0.0.beta test/row_reader_test.rb