Sha256: 0c246852f23d4d1eff61d1b2e3948f51dbffe9ba996bb1b096ee6a13debccaa5

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require_relative 'test_helper'

# Unit Test for IOStreams::Gzip
module Streams
  class GzipWriterTest < Minitest::Test
    context IOStreams::Gzip::Writer do
      setup do
        @file_name = File.join(File.dirname(__FILE__), 'files', 'text.txt.gz')
        @data = Zlib::GzipReader.open(@file_name) {|gz| gz.read }
      end

      context '.open' do
        should 'file' do
          temp_file = Tempfile.new('rocket_job')
          file_name = temp_file.to_path
          IOStreams::Gzip::Writer.open(file_name) do |io|
            io.write(@data)
          end
          result = Zlib::GzipReader.open(file_name) {|gz| gz.read }
          temp_file.delete
          assert_equal @data, result
        end
        should 'stream' do
          io_string = StringIO.new(''.force_encoding('ASCII-8BIT'))
          IOStreams::Gzip::Writer.open(io_string) do |io|
            io.write(@data)
          end
          io = StringIO.new(io_string.string)
          gz = Zlib::GzipReader.new(io)
          data = gz.read
          gz.close
          assert_equal @data, data
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iostreams-0.8.0 test/gzip_writer_test.rb
iostreams-0.7.0 test/gzip_writer_test.rb