Sha256: a4a85a2f20bc2565a56697d5884a77e22bcb106695fdbb955227f382e24c7374

Contents?: true

Size: 1019 Bytes

Versions: 14

Compression:

Stored size: 1019 Bytes

Contents

require_relative 'test_helper'

class GzipWriterTest < Minitest::Test
  describe IOStreams::Gzip::Writer do
    let :temp_file do
      Tempfile.new('iostreams')
    end

    let :file_name do
      temp_file.path
    end

    let :decompressed do
      File.read(File.join(File.dirname(__FILE__), 'files', 'text.txt'))
    end

    after do
      temp_file.delete
    end

    describe '.open' do
      it 'file' do
        IOStreams::Gzip::Writer.open(file_name) do |io|
          io.write(decompressed)
        end
        result = Zlib::GzipReader.open(file_name) { |gz| gz.read }
        temp_file.delete
        assert_equal decompressed, result
      end

      it 'stream' do
        io_string = StringIO.new(''.b)
        IOStreams::Gzip::Writer.open(io_string) do |io|
          io.write(decompressed)
        end
        io   = StringIO.new(io_string.string)
        gz   = Zlib::GzipReader.new(io)
        data = gz.read
        gz.close
        assert_equal decompressed, data
      end
    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
iostreams-0.20.3 test/gzip_writer_test.rb
iostreams-0.20.2 test/gzip_writer_test.rb
iostreams-0.20.1 test/gzip_writer_test.rb
iostreams-0.20.0 test/gzip_writer_test.rb
iostreams-0.19.0 test/gzip_writer_test.rb
iostreams-0.18.0 test/gzip_writer_test.rb
iostreams-0.17.3 test/gzip_writer_test.rb
iostreams-0.17.2 test/gzip_writer_test.rb
iostreams-0.17.1 test/gzip_writer_test.rb
iostreams-0.17.0 test/gzip_writer_test.rb
iostreams-0.16.2 test/gzip_writer_test.rb
iostreams-0.16.1 test/gzip_writer_test.rb
iostreams-0.16.0 test/gzip_writer_test.rb
iostreams-0.15.0 test/gzip_writer_test.rb