Sha256: 9d64cd30255b5d13597836680e24a774081dcafb500292aa6f8119fcd7335cdc

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe Harvestdor::Indexer::PurlFetcher do
  describe '#druids_from_collection' do
    let(:client) { subject.send(:client) }

    before do
      allow(client).to receive(:get).with('/collections/druid:oo000oo0000/purls', page: 1, per_page: 100).and_return(
        instance_double(Faraday::Response, body: { purls: [{ druid: 'druid:oo000oo0001' }], pages: { next_page: 2 } }.to_json)
      )
      allow(client).to receive(:get).with('/collections/druid:oo000oo0000/purls', page: 2, per_page: 100).and_return(
        instance_double(Faraday::Response, body: { purls: [{ druid: 'druid:oo000oo0002' }], pages: { next_page: 3 } }.to_json)
      )
      allow(client).to receive(:get).with('/collections/druid:oo000oo0000/purls', page: 3, per_page: 100).and_return(
        instance_double(Faraday::Response, body: { purls: [{ druid: 'druid:oo000oo0003' }], pages: { next_page: nil } }.to_json)
      )
    end

    it 'returns an enumerable of druids from a collection' do
      results = subject.druids_from_collection('druid:oo000oo0000')

      expect(results.to_a).to match_array %w(druid:oo000oo0001 druid:oo000oo0002 druid:oo000oo0003)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
harvestdor-indexer-2.5.0 spec/unit/harvestdor/indexer/purl_fetcher_spec.rb