spec/lib/adapters/rabbitmq_adapter_spec.rb in basquiat-1.3.6 vs spec/lib/adapters/rabbitmq_adapter_spec.rb in basquiat-1.4.0

- old
+ new

@@ -20,13 +20,35 @@ after(:each) do remove_queues_and_exchanges end context 'publisher' do - it '#publish [enqueue a message]' do - expect do - adapter.publish('messages.welcome', data: 'A Nice Welcome Message') - end.to_not raise_error + context 'main process' do + it '#publish [enqueue a message]' do + expect do + adapter.publish('messages.welcome', data: 'A Nice Welcome Message') + end.to_not raise_error + end + end + + context 'multiple threads' do + let(:base_options) do + { connection: { hosts: [ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_ADDR') { 'localhost' }], + port: ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_PORT') { 5672 } }, + publisher: { persistent: true, session_pool: { size: 10 } } } + end + + it '#publish [enqueue a message 10 times concurrently]' do + expect do + threads = [] + + 10.times do + threads << Thread.new { adapter.publish('messages.welcome', data: 'A Nice Welcome Message') } + end + + threads.each(&:join) + end.not_to raise_error + end end end context 'listener' do it 'runs the rescue block when an exception happens' do