Skip to content

Commit

Permalink
Dor::TextExtraction::Abbyy::FileWatcher spec: test event creation at …
Browse files Browse the repository at this point in the history
…the level of abstraction used in the class

this follows a refactoring to consistently use Dor::TextExtraction::DorEventLogger (instead of Dor::Services::Client) for event creation
  • Loading branch information
jmartin-sul committed Nov 26, 2024
1 parent acee8de commit 1f2dabc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions spec/lib/dor/text_extraction/abbyy/file_watcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
let(:druid) { "druid:#{bare_druid}" }
let(:logger) { instance_double(Logger) }
let(:workflow_updater) { instance_double(Dor::TextExtraction::WorkflowUpdater) }
let(:object_client) { instance_double(Dor::Services::Client::Object) }
let(:events_client) { instance_double(Dor::Services::Client::Events) }
let(:dor_event_logger) { instance_double(Dor::TextExtraction::DorEventLogger, create_event: nil) }
let(:listener_options) { { force_polling: true } }
let(:file_watcher) { described_class.new(logger:, listener_options:) }

Expand All @@ -21,12 +20,9 @@
)
allow(Dor::TextExtraction::WorkflowUpdater).to receive(:new).and_return(workflow_updater)
allow(Honeybadger).to receive(:notify)
allow(Dor::Services::Client).to receive(:configure)
allow(Dor::Services::Client).to receive(:object).and_return(object_client)
allow(Dor::TextExtraction::DorEventLogger).to receive(:new).with(logger:).and_return(dor_event_logger)
allow(workflow_updater).to receive(:mark_ocr_create_errored)
allow(workflow_updater).to receive(:mark_ocr_create_completed)
allow(object_client).to receive(:events).and_return(events_client)
allow(events_client).to receive(:create)
allow(logger).to receive(:info)
end

Expand Down Expand Up @@ -58,8 +54,9 @@
end

it 'publishes an event' do
expect(events_client).to have_received(:create).with(
expect(dor_event_logger).to have_received(:create_event).with(
{
druid:,
type: 'ocr_success',
data: a_hash_including({ software_name: 'ABBYY FineReader Server', software_version: '14.0' })
}
Expand Down Expand Up @@ -91,8 +88,9 @@
end

it 'publishes an event' do
expect(events_client).to have_received(:create).with(
expect(dor_event_logger).to have_received(:create_event).with(
{
druid:,
type: 'ocr_errored',
data: a_hash_including({ software_name: 'ABBYY FineReader Server', errors: failure_messages })
}
Expand Down

0 comments on commit 1f2dabc

Please sign in to comment.