Skip to content

Instantly share code, notes, and snippets.

@waldofe
Created May 6, 2015 19:54
Show Gist options
  • Save waldofe/50b1d63e41de0ac46505 to your computer and use it in GitHub Desktop.
Save waldofe/50b1d63e41de0ac46505 to your computer and use it in GitHub Desktop.
Testing Job call on model
# test
describe '#initialize_delayed_recharge_process' do
subject { create :transport_service_recharge_batch }
let(:calculation_job) do
instance_double(RH::TransportRechargeBatchCalculationJob)
end
it 'calls DelayedJob#enqueue on RH::TransportRechargeBatchCalculationJob' do
expect(RH::TransportRechargeBatchCalculationJob).to receive(:new).
with(id: subject.id).and_return(calculation_job)
expect(Delayed::Job).to receive(:enqueue).with(calculation_job)
subject.initialize_delayed_recharge_process
end
end
#model
def initialize_delayed_recharge_process
Delayed::Job.enqueue RH::TransportRechargeBatchCalculationJob.new(id: id)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment