Sha256: 4b3b4bd133f0c9c6044297504b20248e52670b4dfa23a51e5cdaa395a21c69ec

Contents?: true

Size: 811 Bytes

Versions: 3

Compression:

Stored size: 811 Bytes

Contents

require 'spec_helper'

RSpec.describe NewspaperArticleIndexer do
  let(:article) do
    NewspaperArticle.new(
      id: 'foo1234',
      title: ['Whatever'],
      genre: %w[http://id.loc.gov/vocabulary/graphicMaterials/tgm000098 FOO]
    )
  end
  let(:indexer) { described_class.new(article) }

  describe '#generate_solr_document' do
    subject { indexer.generate_solr_document }

    it 'adds the correct fields to the Solr document' do
      expect(subject['genre_tesim']).not_to be_falsey
      expect(subject['genre_sim']).not_to be_falsey
    end

    it 'indexes genre terms with a URI correctly' do
      expect(subject['genre_tesim']).to include('Advertisement')
    end

    it 'indexes genre terms without a URI correctly' do
      expect(subject['genre_sim']).to include('FOO')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newspaper_works-1.0.1 spec/indexers/newspaper_article_indexer_spec.rb
newspaper_works-1.0.0 spec/indexers/newspaper_article_indexer_spec.rb
newspaper_works-0.1.0 spec/indexers/newspaper_article_indexer_spec.rb