Sha256: e34292b57c6b7b3b4335dfd0720e409f02a3bc4eae403326052d34a22792262e

Contents?: true

Size: 1.6 KB

Versions: 6

Compression:

Stored size: 1.6 KB

Contents

require 'spec_helper'

RSpec.describe BlacklightOaiProvider::SolrDocumentWrapper do
  subject(:wrapper) { described_class.new(controller, options) }

  let(:options) { {} }
  let(:controller) { CatalogController.new }

  before do
    allow(controller).to receive(:params).and_return({})
  end

  describe '#initialize' do
    context 'with a set class provided' do
      before do
        stub_const 'CustomSet', Class.new(BlacklightOaiProvider::Set)
      end

      let(:options) { { set_model: CustomSet, set_fields: [{ solr_field: 'language_facet' }] } }

      it 'uses the Set class' do
        expect(wrapper.instance_eval { @set }).to be CustomSet
      end
    end
  end

  describe '#sets' do
    it 'returns nil to indicate sets are not supported' do
      expect(wrapper.sets).to be_nil
    end
  end

  describe '#earliest' do
    it 'returns the earliest timestamp of all the records' do
      expect(wrapper.earliest).to eq Time.parse('2014-02-03 18:42:53.056000000 +0000').utc
    end
  end

  describe '#latest' do
    it 'returns the latest timestamp of all the records' do
      expect(wrapper.latest).to eq Time.parse('2014-03-03 18:42:53.056000000 +0000').utc
    end
  end

  describe '#find' do
    context 'when selector is :all' do
      it 'returns a limited list of all records' do
        expect(wrapper.find(:all)).to be_a OAI::Provider::PartialResult
        expect(wrapper.find(:all).records.size).to be 15
      end
    end

    context 'when selector is an individual record' do
      it 'returns a single record' do
        expect(wrapper.find('2005553155')).to be_a SolrDocument
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
blacklight_oai_provider-6.0.0 spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
blacklight_oai_provider-6.0.0.pre2 spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
blacklight_oai_provider-6.0.0.pre1 spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
blacklight_oai_provider-5.1.0 spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
blacklight_oai_provider-5.0.0 spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb
blacklight_oai_provider-5.0.0.pre1 spec/lib/blacklight_oai_provider/solr_document_wrapper_spec.rb