Sha256: e4da61f5ff597e2c9e225ca9511a11af4ea4d279b0564a6158067716a85b7a80

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'
require 'resync/client/zip_package'

module Resync
  describe ZipPackage do
    describe '#new' do
      it 'accepts a path to a ZIP file' do
        path = 'spec/data/resourcedump/resourcedump.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/resourcedump.zip')
        pkg = ZipPackage.new(zipfile)
        expect(pkg.zipfile).to eq(zipfile)
      end

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

      it 'extracts entries' do
        pkg = ZipPackage.new('spec/data/resourcedump/resourcedump.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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
resync-client-0.1.2 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.1.1 spec/unit/resync/client/zip_package_spec.rb
resync-client-0.1.0 spec/unit/resync/client/zip_package_spec.rb