Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples for raising errors #10

Open
dsandstrom opened this issue Apr 8, 2016 · 1 comment
Open

Examples for raising errors #10

dsandstrom opened this issue Apr 8, 2016 · 1 comment

Comments

@dsandstrom
Copy link
Contributor

Can you provide an example on how to raise Bunny::ConnectionClosedError and Bunny::TCPConnectionFailed errors. I'm having trouble getting these to fire.

Maybe something like:

it 'should route messages from exchanges' do
  channel = BunnyMock.new.start.channel

  xchg = channel.topic 'xchg.topic'
  queue = channel.queue 'queue.test'

  queue.bind xchg
  allow(xchg).to receive(:publish).and_raise(Bunny::ConnectionClosedError)
  xchg.publish 'Routed message', routing_key: '*.test'

  expect(queue.message_count).to eq(1)
  expect(queue.pop[:message]).to eq('Routed message')
end
@arempe93
Copy link
Owner

arempe93 commented Apr 8, 2016

Hmmm....perhaps I can have a toggle to simulate certain errors. Something like

session.simulate_connection_closed!

expect {  xchg.publish('Routed message', routing_key: '*.test') }.to raise_error(Bunny::ConnectionClosedError)
expect(error_handler).to do_stuff

I'll have to look at this and the relevant Bunny code to see what the actual implementation of that might look like tonight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants