Sha256: 132afffd8a4fd199545a9cc956a8ae6f6d692ecbca0175efd2a53bcf38c47c19

Contents?: true

Size: 1021 Bytes

Versions: 9

Compression:

Stored size: 1021 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 '.file' do
      it 'file' do
        IOStreams::Gzip::Writer.file(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.stream(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

9 entries across 9 versions & 1 rubygems

Version Path
iostreams-1.1.0 test/gzip_writer_test.rb
iostreams-1.0.0 test/gzip_writer_test.rb
iostreams-1.0.0.beta7 test/gzip_writer_test.rb
iostreams-1.0.0.beta6 test/gzip_writer_test.rb
iostreams-1.0.0.beta5 test/gzip_writer_test.rb
iostreams-1.0.0.beta4 test/gzip_writer_test.rb
iostreams-1.0.0.beta3 test/gzip_writer_test.rb
iostreams-1.0.0.beta2 test/gzip_writer_test.rb
iostreams-1.0.0.beta test/gzip_writer_test.rb