Sha256: ff9ec6081a0a2706fd6b4e12d524e617d0b64bcc88f0ae4c4120bcf04326d74a

Contents?: true

Size: 876 Bytes

Versions: 1

Compression:

Stored size: 876 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

1 entries across 1 versions & 1 rubygems

Version Path
iostreams-0.8.2 test/file_writer_test.rb