Sha256: 92a6251585ed83920e698429e628107508ac98cc5a640102a3606d25e05af305

Contents?: true

Size: 1.68 KB

Versions: 59

Compression:

Stored size: 1.68 KB

Contents

require 'test_helper'

class BasicZipFileTest < MiniTest::Test
  include AssertEntry

  def setup
    @zip_file = ::Zip::File.new(TestZipFile::TEST_ZIP2.zip_name)
    @testEntryNameIndex = 0
  end

  def test_entries
    assert_equal(TestZipFile::TEST_ZIP2.entry_names.sort,
                 @zip_file.entries.entries.sort.map { |e| e.name })
  end

  def test_each
    count = 0
    visited = {}
    @zip_file.each do |entry|
      assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
      assert(!visited.include?(entry.name))
      visited[entry.name] = nil
      count = count.succ
    end
    assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
  end

  def test_foreach
    count = 0
    visited = {}
    ::Zip::File.foreach(TestZipFile::TEST_ZIP2.zip_name) do |entry|
      assert(TestZipFile::TEST_ZIP2.entry_names.include?(entry.name))
      assert(!visited.include?(entry.name))
      visited[entry.name] = nil
      count = count.succ
    end
    assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
  end

  def test_get_input_stream
    count = 0
    visited = {}
    @zip_file.each do |entry|
      assert_entry(entry.name, @zip_file.get_input_stream(entry), entry.name)
      assert(!visited.include?(entry.name))
      visited[entry.name] = nil
      count = count.succ
    end
    assert_equal(TestZipFile::TEST_ZIP2.entry_names.length, count)
  end

  def test_get_input_stream_block
    fileAndEntryName = @zip_file.entries.first.name
    @zip_file.get_input_stream(fileAndEntryName) do |zis|
      assert_entry_contents_for_stream(fileAndEntryName,
                                       zis,
                                       fileAndEntryName)
    end
  end
end

Version data entries

59 entries across 47 versions & 5 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.3/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rubyzip-1.2.1/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rubyzip-1.3.0/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/basic_zip_file_test.rb
rubyzip-1.3.0 test/basic_zip_file_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.4/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
rubyzip-1.2.4 test/basic_zip_file_test.rb
rubyzip-1.2.3 test/basic_zip_file_test.rb
tdiary-5.0.13 vendor/bundle/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
tdiary-5.0.12.1 vendor/bundle/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
tdiary-5.0.11 vendor/bundle/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb
tdiary-5.0.11 vendor/bundle/gems/rubyzip-1.2.1/test/basic_zip_file_test.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/rubyzip-1.2.2/test/basic_zip_file_test.rb