Replace no-op stub with full perform body: find delivery by id, skip if blank, delegate to Captain::Lifecycle::Dispatcher#call. Add retry_on with polynomially_longer backoff (3 attempts). Spec covers dispatcher delegation and graceful skip for missing records. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
634 B
Ruby
23 lines
634 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Captain::Lifecycle::DispatcherJob do
|
|
let(:delivery) { create(:captain_lifecycle_delivery) }
|
|
|
|
it 'calls Dispatcher#call' do
|
|
dispatcher = instance_double(Captain::Lifecycle::Dispatcher)
|
|
expect(Captain::Lifecycle::Dispatcher)
|
|
.to receive(:new)
|
|
.with(instance_of(Captain::Lifecycle::Delivery))
|
|
.and_return(dispatcher)
|
|
expect(dispatcher).to receive(:call)
|
|
|
|
described_class.perform_now(delivery.id)
|
|
end
|
|
|
|
it 'silently skips missing delivery records' do
|
|
expect { described_class.perform_now(-1) }.not_to raise_error
|
|
end
|
|
end
|