Sha256: cb8999504b80308abb72fcd1c7792ca13ab5bd9b39d5d06ddd100dca6c2ab126

Contents?: true

Size: 1.71 KB

Versions: 33

Compression:

Stored size: 1.71 KB

Contents

require 'spec_helper'

describe Spotlight::Resources::IiifService do
  let(:url) { 'uri://for-top-level-collection' }
  subject { described_class.new(url) }
  before { stub_default_collection }

  describe '#collections' do
    it 'returns service objects for each top-level collection' do
      expect(subject.collections.length).to eq 2
      expect(subject.collections).to be_all { |s| s.is_a?(described_class) }
    end

    it 'returns service objects for nested collections' do
      expect(subject.collections.first.collections.length).to eq 1
      expect(subject.collections.last.collections).to be_blank
      expect(subject.collections.first.collections.first).to be_a(described_class)
      expect(
        subject.collections.first.collections.first.collections
      ).to be_blank
    end
  end

  describe '#manifests' do
    it 'returns manifests for the current service level' do
      expect(subject.manifests.length).to eq 2
      expect(subject.manifests.first).to be_a Spotlight::Resources::IiifManifest
      expect(subject.collections.first.manifests.length).to eq 2
      expect(
        subject.collections.first.manifests.first
      ).to be_a Spotlight::Resources::IiifManifest
    end
  end

  describe '#parse' do
    let(:manifests) { described_class.parse(url) }

    it 'recursively traverses all all the collections and returns manifests' do
      expect(manifests).to be_all do |manifest|
        manifest.is_a?(Spotlight::Resources::IiifManifest)
      end
    end

    it 'returns manifests representing collection documents' do
      expect(manifests.count).to eq 8
    end
    it 'keeps track of the parent collection' do
      arr = manifests.to_a
      expect(arr[1].collection).to eq arr[0]
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.4.0 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.3.3 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.3.2 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.3.1 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.3.0 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.2.1 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.2.0 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.1.0 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.2 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.1 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0.rc6 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0.rc5 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0.rc4 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0.rc3 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0.rc2 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-2.0.0.rc1 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-1.5.1 spec/models/spotlight/resources/iiif_service_spec.rb
blacklight-spotlight-1.4.1 spec/models/spotlight/resources/iiif_service_spec.rb