Sha256: 9001f7414e096d53c5a7265979c0b57e8585347339f44560760544ee57d8fe97
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' describe PerfectQueue::TaskMonitor do describe '#kill_task' do it 'rescues exception' do tm = PerfectQueue::TaskMonitor.new(logger: double('logger').as_null_object) task = double('task') reason = double('reason') allow(task).to receive_message_chain(:runner, :kill) \ .with(no_args).with(reason){raise} tm.instance_variable_set(:@task, task) expect{tm.kill_task(reason)}.to raise_error(RuntimeError) end end describe '#external_task_heartbeat' do it 'rescues exception' do tm = PerfectQueue::TaskMonitor.new(logger: double('logger').as_null_object) task = double('task') reason = double('reason') allow(task).to receive_message_chain(:runner, :kill) \ .with(no_args).with(reason){raise} epoch = double('epoch') allow(Time).to receive_message_chain(:now, :to_i){epoch} ret = double('ret') tm.instance_variable_set(:@task, task) expect(tm.external_task_heartbeat(task){ret}).to eq(ret) expect(tm.instance_variable_get(:@last_task_heartbeat)).to eq(epoch) end end describe '#run' do it 'rescues exception' do config = {logger: double('logger').as_null_object} force_stop = double('force_stop') expect(force_stop).to receive(:call).with(no_args).exactly(:once) tm = PerfectQueue::TaskMonitor.new(config, nil, force_stop) allow(Time).to receive(:now){raise} tm.run end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
perfectqueue-0.8.45 | spec/task_monitor_spec.rb |