Sha256: d1ab68db0fee27bf83547a69eb374fe9ab51927a9c85830a44dc615407bffcbd
Contents?: true
Size: 1.98 KB
Versions: 16
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' describe DispatchRider::Handlers::Base do class NoProcessImplemented < DispatchRider::Handlers::Base end class ProcessImplemented < DispatchRider::Handlers::Base def process(_options) "good job" end end class ProcessWithImmediateRetry < DispatchRider::Handlers::Base def process(_options) raise "I have failed!" end def retry_timeout :immediate end end class ProcessWithTenSecondRetry < DispatchRider::Handlers::Base def process(_options) raise "I have failed!" end def retry_timeout 10 * 60 end end describe "#do_process" do let(:message) do double(:message, subject: 'some_message', body: { 'guid' => DispatchRider::Debug::PUBLISHER_MESSAGE_GUID }) end context "when class doesn't implement process" do let(:handler) { NoProcessImplemented.new } example do expect { handler.do_process(message) }.to raise_exception NotImplementedError, "Method 'process' not overridden in subclass!" end end context "when the class does implement process" do let(:handler) { ProcessImplemented.new } example do expect { handler.do_process(message) }.to_not raise_exception end example do expect(handler.do_process(message)).to eq("good job") end end context "when the class wants to immediately retry" do let(:handler) { ProcessWithImmediateRetry.new } example do expect(message).to receive(:return_to_queue) expect { handler.do_process(message) }.to raise_exception "I have failed!" end end context "when the class wants to retry in 10 seconds" do let(:handler) { ProcessWithTenSecondRetry.new } example do expect(message).to receive(:extend_timeout).with(10 * 60) expect { handler.do_process(message) }.to raise_exception "I have failed!" end end end end
Version data entries
16 entries across 16 versions & 1 rubygems