Sha256: d8859da138fcc135ede511fd9119c199b86f696c70014a797c3a798b8e3cb50d

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 KB

Contents

require_relative 'test_helper'
require 'zip'

class ZipWriterTest < Minitest::Test
  describe IOStreams::Zip::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::Zip::Writer.open(file_name, zip_file_name: 'text.txt') do |io|
          io.write(decompressed)
        end
        result = Zip::File.open(file_name) do |zip_file|
          zip_file.first.get_input_stream.read
        end
        assert_equal decompressed, result
      end

      it 'stream' do
        io_string = StringIO.new(''.b)
        IOStreams::Zip::Writer.open(io_string) do |io|
          io.write(decompressed)
        end
        io     = StringIO.new(io_string.string)
        result = nil
        begin
          zin = ::Zip::InputStream.new(io)
          zin.get_next_entry
          result = zin.read
        ensure
          zin.close if zin
        end
        assert_equal decompressed, result
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

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