Sha256: 1ce3032cfd4e8f6ec4e8cd5644e6907bd88d43721f053fef08c8e08807e8be00

Contents?: true

Size: 877 Bytes

Versions: 9

Compression:

Stored size: 877 Bytes

Contents

require_relative 'test_helper'

# Unit Test for IOStreams::File
module Streams
  class FileWriterTest < Minitest::Test
    describe IOStreams::File::Writer do
      before do
        @file_name = File.join(File.dirname(__FILE__), 'files', 'text.txt')
        @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::File::Writer.open(file_name) do |io|
            io.write(@data)
          end
          result = File.read(file_name)
          assert_equal @data, result
        end

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