Sha256: 8d187d514ed3553f7c59cd4bf24fc01686ba6eebef54e238e64368d510b8dc3f

Contents?: true

Size: 956 Bytes

Versions: 9

Compression:

Stored size: 956 Bytes

Contents

require_relative 'test_helper'
require 'csv'

module Streams
  class CSVWriterTest < Minitest::Test
    describe IOStreams::CSV::Writer do
      before do
        @file_name    = File.join(File.dirname(__FILE__), 'files', 'test.csv')
        @data         = ::CSV.read(@file_name)
        @raw_csv_data = ::File.read(@file_name)
      end

      describe '.open' do
        it 'file' do
          temp_file = Tempfile.new('rocket_job')
          file_name = temp_file.to_path
          IOStreams::CSV::Writer.open(file_name) do |io|
            @data.each { |row| io << row }
          end
          result = File.read(file_name)
          assert_equal @raw_csv_data, result
        end

        it 'stream' do
          io_string = StringIO.new
          IOStreams::CSV::Writer.open(io_string) do |io|
            @data.each { |row| io << row }
          end
          assert_equal @raw_csv_data, io_string.string
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-0.14.0 test/csv_writer_test.rb
iostreams-0.13.0 test/csv_writer_test.rb
iostreams-0.12.1 test/csv_writer_test.rb
iostreams-0.12.0 test/csv_writer_test.rb
iostreams-0.11.0 test/csv_writer_test.rb
iostreams-0.10.1 test/csv_writer_test.rb
iostreams-0.10.0 test/csv_writer_test.rb
iostreams-0.9.1 test/csv_writer_test.rb
iostreams-0.9.0 test/csv_writer_test.rb