Sha256: 7fee47c5eb068be5a6827e6b40358deedefb3b1a39aa9f20e0034362f576cb4f

Contents?: true

Size: 1.96 KB

Versions: 11

Compression:

Stored size: 1.96 KB

Contents

require 'spec_helper'

module Resync
  class Client
    module Zip
      describe ZipPackage do
        describe '#new' do
          it 'accepts a path to a ZIP file' do
            path = 'spec/data/resourcedump/bitstream-package.zip'
            pkg = ZipPackage.new(path)
            zipfile = pkg.zipfile
            expect(zipfile).to be_a(::Zip::File)
            expect(zipfile.name).to eq(path)
          end

          it 'accepts a Zip::File object' do
            zipfile = ::Zip::File.open('spec/data/resourcedump/bitstream-package.zip')
            pkg = ZipPackage.new(zipfile)
            expect(pkg.zipfile).to eq(zipfile)
          end

          it 'extracts a manifest' do
            pkg = ZipPackage.new('spec/data/resourcedump/bitstream-package.zip')
            manifest = pkg.manifest
            expect(manifest).to be_a(Resync::ResourceDumpManifest)
          end

          it 'extracts entries' do
            pkg = ZipPackage.new('spec/data/resourcedump/bitstream-package.zip')
            bitstreams = pkg.bitstreams
            expect(bitstreams.size).to eq(2)

            bs0 = bitstreams[0]
            expect(bs0.path).to eq('resources/res1')
            expect(bs0.size).to eq(446)
            expect(bs0.content).to eq(File.read('spec/data/resourcedump/resources/res1'))

            bs1 = bitstreams[1]
            expect(bs1.path).to eq('resources/res2')
            expect(bs1.size).to eq(447)
            expect(bs1.content).to eq(File.read('spec/data/resourcedump/resources/res2'))
          end

          it 'provides direct access to bitstreams for each resource in the manifest' do
            pkg = ZipPackage.new('spec/data/resourcedump/bitstream-package.zip')
            bitstreams = pkg.bitstreams

            manifest = pkg.manifest
            resources = manifest.resources

            resources.each_with_index do |r, i|
              expect(r.bitstream).to be(bitstreams[i])
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
resync-client-0.4.7 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.6 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.5 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.4 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.3 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.2 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.1 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.4.0 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.3.5 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.3.4 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.3.3 spec/unit/resync/client/zip_package_spec.rb