Sha256: 60cc8cfb0fa2ada22b41eaed800557c06db94f85174f835093d9d7099b7805dd

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require "keyed_archive/unpacked_objects"

shared_examples "unpack" do
  it "should unpack objects" do
    keyed_archive = KeyedArchive.new(:file => filename)
    unpacked_top = keyed_archive.unpacked_top()
    fixture_archive = KeyedArchive.new(:file => fixture)
    expect(unpacked_top["root"]).to eq(fixture_archive.objects[1]["key"])
  end

  it "should handle variables" do
    keyed_archive = KeyedArchive.new(:data => blob)
    unpacked_top = keyed_archive.unpacked_top()
    fixture_archive = KeyedArchive.new(:file => fixture)
    expect(unpacked_top["root"]).to eq(fixture_archive.objects[1]["key"])
  end
end

describe KeyedArchive, "#unpack" do
  context "single reference" do
    it_behaves_like "unpack" do
      let(:filename) { "spec/fixtures/single_object_reference.plist" }
      let(:blob) { File.read("spec/fixtures/single_object_reference.plist") }
      let(:fixture) { "spec/fixtures/single_object_reference_unpacked.plist" }
    end
  end

  context "double reference" do
    it_behaves_like "unpack" do
      let(:filename) { "spec/fixtures/double_object_reference.plist" }
      let(:blob) { File.read("spec/fixtures/double_object_reference.plist") }
      let(:fixture) { "spec/fixtures/double_object_reference_unpacked.plist" }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
keyed_archive-1.1.0 spec/unpacked_objects_spec.rb
keyed_archive-1.0.0 spec/unpacked_objects_spec.rb