Sha256: 889716608ddd4a4005665061f8fca94edf6793c7009fa70711568bd440842e9e

Contents?: true

Size: 1007 Bytes

Versions: 19

Compression:

Stored size: 1007 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, &: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

19 entries across 19 versions & 1 rubygems

Version Path
iostreams-1.10.2 test/gzip_writer_test.rb
iostreams-1.10.1 test/gzip_writer_test.rb
iostreams-1.10.0 test/gzip_writer_test.rb
iostreams-1.9.0 test/gzip_writer_test.rb
iostreams-1.8.0 test/gzip_writer_test.rb
iostreams-1.7.0 test/gzip_writer_test.rb
iostreams-1.6.2 test/gzip_writer_test.rb
iostreams-1.6.1 test/gzip_writer_test.rb
iostreams-1.6.0 test/gzip_writer_test.rb
iostreams-1.5.1 test/gzip_writer_test.rb
iostreams-1.5.0 test/gzip_writer_test.rb
iostreams-1.4.0 test/gzip_writer_test.rb
iostreams-1.3.3 test/gzip_writer_test.rb
iostreams-1.3.2 test/gzip_writer_test.rb
iostreams-1.3.1 test/gzip_writer_test.rb
iostreams-1.3.0 test/gzip_writer_test.rb
iostreams-1.2.1 test/gzip_writer_test.rb
iostreams-1.2.0 test/gzip_writer_test.rb
iostreams-1.1.1 test/gzip_writer_test.rb