spec/lib/dispatch-rider/handlers/base_spec.rb in dispatch-rider-1.5.3 vs spec/lib/dispatch-rider/handlers/base_spec.rb in dispatch-rider-1.6.0
- old
+ new
@@ -3,79 +3,84 @@
describe DispatchRider::Handlers::Base do
class NoProcessImplemented < DispatchRider::Handlers::Base
end
class ProcessImplemented < DispatchRider::Handlers::Base
- def process(options)
+ def process(_options)
"good job"
end
end
-
+
class ProcessWithImmediateRetry < DispatchRider::Handlers::Base
- def process(options)
+ def process(_options)
raise "I have failed!"
end
-
- def retry_timeout; :immediate; end
+
+ def retry_timeout
+ :immediate
+ end
end
-
+
class ProcessWithTenSecondRetry < DispatchRider::Handlers::Base
- def process(options)
+ def process(_options)
raise "I have failed!"
end
-
- def retry_timeout; 10*60; end
+
+ def retry_timeout
+ 10 * 60
+ end
end
describe "#do_process" do
- let(:message){ double(:message, subject: 'some_message', body: { 'guid' => DispatchRider::Debug::PUBLISHER_MESSAGE_GUID }) }
+ 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 }
+ 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 }
+ let(:handler) { ProcessImplemented.new }
example do
expect {
handler.do_process(message)
}.to_not raise_exception
end
example do
- handler.do_process(message).should == "good job"
+ 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
- message.should_receive(:return_to_queue)
-
+ 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
- message.should_receive(:extend_timeout).with(10*60)
-
+ expect(message).to receive(:extend_timeout).with(10 * 60)
+
expect {
handler.do_process(message)
}.to raise_exception "I have failed!"
end
end
end
-
end