Sha256: 66ee341532fc5027bde15d908b8ebefc5a32ca26e84ec1c51d92d2a9528dfcc5

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

require_relative 'test_helper'

module Streams
  class DelimitedWriterTest < Minitest::Test
    describe IOStreams::Delimited::Writer do
      before do
        @file_name = File.join(File.dirname(__FILE__), 'files', 'text.txt')
        @file      = File.read(@file_name)
        @data      = @file.lines
      end

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

        it 'stream' do
          io_string = StringIO.new
          IOStreams::Delimited::Writer.open(io_string) do |io|
            @data.each { |line| io << line.strip }
          end
          assert_equal @file, io_string.string
        end
      end

      describe '.write' do
        it 'writes without delimiter' do
          io_string = StringIO.new
          IOStreams::File::Writer.open(io_string) do |io|
            io.write(@file)
          end
          assert_equal @file, 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/delimited_writer_test.rb
iostreams-0.13.0 test/delimited_writer_test.rb
iostreams-0.12.1 test/delimited_writer_test.rb
iostreams-0.12.0 test/delimited_writer_test.rb
iostreams-0.11.0 test/delimited_writer_test.rb
iostreams-0.10.1 test/delimited_writer_test.rb
iostreams-0.10.0 test/delimited_writer_test.rb
iostreams-0.9.1 test/delimited_writer_test.rb
iostreams-0.9.0 test/delimited_writer_test.rb