Skip to content

Commit

Permalink
✅ Add test for file set indexer logic
Browse files Browse the repository at this point in the history
This commit will add a simple test for the FileSetIndexer logic to check
that the text extraction from a born digital pdf works as expected.
  • Loading branch information
kirkkwang committed Sep 18, 2024
1 parent b666d84 commit 9aa21fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Binary file added spec/fixtures/pdf/pdf_sample.pdf
Binary file not shown.
23 changes: 23 additions & 0 deletions spec/indexers/hyku/indexers/file_set_indexer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

RSpec.describe Hyku::Indexers::FileSetIndexer do
let(:indexer_class) { described_class }
let(:resource) { Hyrax.config.file_set_model.constantize.new }
let(:original_file) { Hyrax::FileMetadata.new }

it 'is the configured file set indexer' do
expect(Hyrax.config.file_set_indexer).to eq described_class
end

describe '#to_solr' do
let(:stream) { File.open('spec/fixtures/pdf/pdf_sample.pdf').read }
it 'indexes the text of a pdf that has text already' do
allow(Flipflop).to receive(:default_pdf_viewer?).and_return(true)
allow(resource).to receive(:original_file).and_return(original_file)
allow(original_file).to receive(:pdf?).and_return(true)
allow(original_file).to receive(:content).and_return(stream)

expect(resource.to_solr['all_text_tsimv']).to include('Dummy PDF file')
end
end
end

0 comments on commit 9aa21fc

Please sign in to comment.