Sha256: fcaf79006a28bbee5372f63d1f3e8a739afca53e5e40b0a9270d3ee6318786a5

Contents?: true

Size: 999 Bytes

Versions: 41

Compression:

Stored size: 999 Bytes

Contents

require 'rubygems/package/tar_test_case'
require 'rubygems/package'

class TestGemPackageTarReader < Gem::Package::TarTestCase

  def test_each_entry
    tar = tar_dir_header "foo", "bar", 0
    tar << tar_file_header("bar", "baz", 0, 0)

    io = TempIO.new tar

    entries = 0

    Gem::Package::TarReader.new io do |tar_reader|
      tar_reader.each_entry do |entry|
        assert_kind_of Gem::Package::TarReader::Entry, entry

        entries += 1
      end
    end

    assert_equal 2, entries
  end

  def test_rewind
    content = ('a'..'z').to_a.join(" ")

    str = tar_file_header("lib/foo", "", 010644, content.size) + content +
            "\0" * (512 - content.size)
    str << "\0" * 1024

    Gem::Package::TarReader.new(TempIO.new(str)) do |tar_reader|
      3.times do
        tar_reader.rewind
        i = 0
        tar_reader.each_entry do |entry|
          assert_equal(content, entry.read)
          i += 1
        end
        assert_equal(1, i)
      end
    end
  end

end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
rubygems-update-1.8.30 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.29 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.28 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.23.2 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.27 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.26 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.25 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.24 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.23 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.22 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.21 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.20 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.19 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.18 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.17 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.16 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.15 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.14 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.13 test/rubygems/test_gem_package_tar_reader.rb
rubygems-update-1.8.12 test/rubygems/test_gem_package_tar_reader.rb