spec/lib/dispatch-rider/dispatcher_spec.rb in dispatch-rider-2.1.0 vs spec/lib/dispatch-rider/dispatcher_spec.rb in dispatch-rider-2.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe DispatchRider::Dispatcher, :nodb => true do
class HandleSomething < DispatchRider::Handlers::Base
def process(params)
@@ -28,20 +30,21 @@
let(:storage) { DispatchRider::Callbacks::Storage.new }
before do
allow(DispatchRider.config).to receive(:callbacks) { storage }
storage.around(:dispatch_message) do |block, message|
- begin
- dummy.before
- dummy.log(message)
- block.call
- ensure
- dummy.after
- end
+
+ dummy.before
+ dummy.log(message)
+ block.call
+ ensure
+ dummy.after
+
end
subject.register('handle_something')
end
+
example do
expect(dummy).to receive(:before).once
expect(dummy).to receive(:after).once
expect(dummy).to receive(:log).with(message).once
catch(:something) do
@@ -49,11 +52,11 @@
end
end
end
context "when the handler provided in the message is present" do
- before :each do
+ before do
subject.register('handle_something')
end
it "should process the message" do
expect { subject.dispatch(message) }.to throw_symbol(:something)
@@ -61,10 +64,10 @@
end
context "when the handler returns false" do
let(:message_subject) { "handler_that_returns_false" }
- before :each do
+ before do
subject.register('handler_that_returns_false')
end
it "should return true indicating message is good to be removed" do
expect(subject.dispatch(message)).to be true