Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- require "bunny"
- describe "RabbitMQ" do
- it 'should send and recieve a message' do
- TestBunny.send("test1", "hello")
- message = TestBunny.subscribe("test1")
- expect(message).to_not eq(nil)
- end
- it 'consumer should recieve the correct message' do
- correct_message = "iamcorrect"
- TestBunny.send("test2", correct_message)
- message = TestBunny.subscribe("test2")
- expect(message).to eq(correct_message)
- end
- it 'should be able to create a new Bunny connection' do
- pass = false
- begin
- TestBunny.connect
- pass = true
- rescue
- end
- expect(pass).to eq(true)
- end
- it 'should send and recieve multiple messages without loss' do
- recieved = 0
- to_send = 10
- to_send.times do
- TestBunny.send("test3", "hello")
- message = TestBunny.subscribe("test3")
- recieved += 1 if !!message
- end
- expect(recieved).to eq(to_send)
- end
- it 'should not accept an integer as a queue' do
- expect {
- TestBunny.send(1, "hello")
- }.to raise_error
- end
- it 'should not accept nil as a queue' do
- expect {
- TestBunny.send(nil, "hello")
- }.to raise_error
- end
- it 'should not accept very large string as a queue' do
- expect {
- TestBunny.send(SecureRandom.hex(200000), "hello")
- }.to raise_error
- end
- it 'should not accept object as a queue' do
- expect {
- TestBunny.send(Object.new, "hello")
- }.to raise_error
- end
- it 'should not accept nil as message' do
- expect {
- TestBunny.send("test4", nil)
- }.to raise_error
- end
- it 'should not accept class as message' do
- expect {
- TestBunny.send("test4", Object)
- }.to raise_error
- end
- it 'should not send a message without a queue' do
- expect {
- TestBunny.send("test4", Object)
- }.to raise_error
- end
- it 'should not send a message without a queue' do
- expect {
- TestBunny.send("test4", Object)
- }.to raise_error
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement