Sha256: 00baedce3a4da08046892b2bb042e9572bcb52189341abe91224d4c8b721992e

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

require_relative 'test_helper'

# Unit Test for IOStreams::File
module Streams
  class FileWriterTest < Minitest::Test
    context IOStreams::File::Writer do
      setup do
        @file_name = File.join(File.dirname(__FILE__), 'files', 'text.txt')
        @data      = File.read(@file_name)
      end

      context '.open' do
        should '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
        should '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

3 entries across 3 versions & 1 rubygems

Version Path
iostreams-0.8.1 test/file_writer_test.rb
iostreams-0.8.0 test/file_writer_test.rb
iostreams-0.7.0 test/file_writer_test.rb