spec/support/shared/subscription_examples.rb in message-driver-0.6.1 vs spec/support/shared/subscription_examples.rb in message-driver-0.7.0
- old
+ new
@@ -3,10 +3,12 @@
it 'returns false' do
expect(subject.supports_subscriptions?).to eq(false)
end
end
+ it { is_expected.not_to override_method(:handle_subscribe) }
+
describe '#subscribe' do
it 'raises an error' do
destination = double('destination')
consumer = ->(_) {}
expect do
@@ -21,10 +23,12 @@
it 'returns true' do
expect(subject.supports_subscriptions?).to eq(true)
end
end
+ it { is_expected.to override_method(:handle_subscribe) }
+
let(:destination) { adapter_context.create_destination('subscriptions_example_queue') }
let(:message1) { 'message 1' }
let(:message2) { 'message 2' }
let(:messages) { [] }
@@ -85,10 +89,11 @@
it 'plays the messages into the consumer' do
expect do
subscription
pause_if_needed
end.to change { messages.size }.from(0).to(2)
+ expect(messages.map(&:destination)).to all(be_a(MessageDriver::Destination::Base))
bodies = messages.map(&:body)
expect(bodies).to include(message1)
expect(bodies).to include(message2)
end
@@ -119,10 +124,10 @@
context 'when the consumer raises an error' do
let(:error) { RuntimeError.new('oh nos!') }
let(:consumer) do
lambda do |_|
- fail error
+ raise error
end
end
before do
destination.publish(message1)