spec/lib/spotlight/dor/indexer_spec.rb in spotlight-dor-resources-0.0.5 vs spec/lib/spotlight/dor/indexer_spec.rb in spotlight-dor-resources-0.0.6
- old
+ new
@@ -48,10 +48,11 @@
end
describe '#add_content_metadata_fields' do
before do
allow(r).to receive(:public_xml).and_return(public_xml)
+ allow(sdb).to receive(:bare_druid).and_return(fake_druid)
# stacks url calculations require the druid
solr_doc[:id] = fake_druid
subject.send(:add_content_metadata_fields, sdb, solr_doc)
@@ -498,10 +499,13 @@
end # each
end # add_folder_name
# rubocop:enable Metrics/LineLength
describe '#add_object_full_text' do
+ before do
+ allow(sdb).to receive(:bare_druid).and_return(fake_druid)
+ end
let!(:expected_text) { 'SOME full text string that is returned from the server' }
let!(:full_file_path) { 'https://stacks.stanford.edu/file/oo000oo0000/oo000oo0000.txt' }
it 'indexes the full text into the appropriate field if a recognized file pattern is found' do
public_xml_with_feigenbaum_full_text = Nokogiri::XML <<-EOF
<publicObject id="druid:oo000oo0000" published="2015-10-17T18:24:08-07:00">
@@ -521,11 +525,11 @@
allow(sdb).to receive(:public_xml).and_return(public_xml_with_feigenbaum_full_text)
# don't actually attempt a call to the stacks
allow(subject).to receive(:get_file_content).with(full_file_path).and_return(expected_text)
subject.send(:add_object_full_text, sdb, solr_doc)
expect(subject.object_level_full_text_urls(sdb)).to eq [full_file_path]
- expect(solr_doc['full_text_tesim']).to eq expected_text
+ expect(solr_doc['full_text_tesim']).to eq [expected_text]
end
it 'does not index the full text if no recognized pattern is found' do
public_xml_with_no_recognized_full_text = Nokogiri::XML <<-EOF
<publicObject id="druid:oo000oo0000" published="2015-10-17T18:24:08-07:00">
<contentMetadata objectId="oo000oo0000" type="book">
@@ -564,9 +568,9 @@
EOF
allow(sdb).to receive(:public_xml).and_return(public_xml_with_two_recognized_full_text_files)
allow(subject).to receive(:get_file_content).with(full_file_path).and_return(expected_text)
subject.send(:add_object_full_text, sdb, solr_doc)
expect(subject.object_level_full_text_urls(sdb)).to eq [full_file_path, full_file_path]
- expect(solr_doc['full_text_tesim']).to eq(expected_text + expected_text) # same file twice
+ expect(solr_doc['full_text_tesim']).to eq [expected_text, expected_text] # same file twice in a 2 element array
end
end # add_object_full_text
end