Module: Rabbit::TestHelpers

Defined in:
lib/rabbit/test_helpers.rb

Instance Method Summary collapse

Instance Method Details

#expect_no_rabbit_messagesObject



17
18
19
# File 'lib/rabbit/test_helpers.rb', line 17

def expect_no_rabbit_messages
  expect(Rabbit).not_to receive(:publish)
end

#expect_rabbit_message(args, strict: true) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/rabbit/test_helpers.rb', line 8

def expect_rabbit_message(args, strict: true)
  expectation = if strict
                  args
                else
                  -> (received_args) { expect(received_args).to match(args) }
                end
  expect(Rabbit).to receive(:publish).with(expectation).once
end

#send_rabbit_message(sender_id, event, data) ⇒ Object



4
5
6
# File 'lib/rabbit/test_helpers.rb', line 4

def send_rabbit_message(sender_id, event, data)
  Rabbit::Receiving::Worker.new.work_with_params(data.to_json, {}, type: event, app_id: sender_id)
end