Sha256: 250907e0268ffa4cf62e6c4f06b369af7d56a37261eca5ac940e4480d5491526

Contents?: true

Size: 1.28 KB

Versions: 8

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Krikri::SearchIndexDocument, type: :model do

  subject do
    Krikri::SearchIndexDocument.new(id: '0123')
  end

  it 'is a SolrDocument' do
    expect(subject).to be_a SolrDocument
  end

  describe '#aggregation' do

    it 'creates a DPLA::MAP::Aggregation with its id' do
      expect(DPLA::MAP::Aggregation).to receive(:new).with('0123')
        .and_return(DPLA::MAP::Aggregation.new('0123'))
      subject.aggregation
    end

    context 'with existing Marmotta record' do

      before :each do
        allow_any_instance_of(DPLA::MAP::Aggregation).to receive(:exists?)
          .and_return(true)
      end

      it 'gets data from Marmotta' do
        expect_any_instance_of(DPLA::MAP::Aggregation).to receive(:get)
        subject.aggregation
      end

      it 'returns a DPLA::MAP::Aggregation' do
        allow_any_instance_of(DPLA::MAP::Aggregation).to receive(:get)
        expect(subject.aggregation)
          .to be_instance_of(DPLA::MAP::Aggregation)
      end
    end

    context 'without existing Marmotta record' do

      before :each do
        allow_any_instance_of(DPLA::MAP::Aggregation).to receive(:exists?)
          .and_return(false)
      end

      it 'returns nil' do
        expect(subject.aggregation).to be_nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
krikri-0.3.3 spec/models/search_index_document_spec.rb
krikri-0.3.2 spec/models/search_index_document_spec.rb
krikri-0.3.1 spec/models/search_index_document_spec.rb
krikri-0.2.1 spec/models/search_index_document_spec.rb
krikri-0.2.0 spec/models/search_index_document_spec.rb
krikri-0.1.3 spec/models/search_index_document_spec.rb
krikri-0.1.2 spec/models/search_index_document_spec.rb
krikri-0.1.1 spec/models/search_index_document_spec.rb