File: declare_and_immediately_bind_a_server_named_queue_spec.rb

package info (click to toggle)
ruby-amqp 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,508 kB
  • sloc: ruby: 8,272; sh: 11; makefile: 10
file content (63 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# encoding: utf-8

require 'spec_helper'

describe "Server-named", AMQP::Queue do

  #
  # Environment
  #

  include EventedSpec::AMQPSpec

  default_timeout 2


  #
  # Examples
  #


  context "bound to a pre-defined exchange" do
    it "delays binding until after queue.declare-ok arrives" do
      mailbox  = []
      channel  = AMQP::Channel.new
      exchange = channel.fanout("amq.fanout")
      input    = "Independencia de resolución, ¿una realidad en Mac OS X Lion?"

      channel.queue("", :auto_delete => true).bind(exchange).subscribe do |header, body|
        mailbox << body
      end

      delayed(0.5) {
        exchange.publish(input)
      }

      done(1.0) {
        mailbox.size.should == 1
      }
    end
  end


  context "bound to a pre-defined exchange" do
    it "delays binding until after queue.declare-ok arrives" do
      mailbox  = []
      channel  = AMQP::Channel.new
      exchange = channel.fanout("amqpgem.examples.exchanges.fanout", :durable => false)
      input    = "Just send me already"

      channel.queue("", :auto_delete => true).bind(exchange).subscribe do |header, body|
        mailbox << body
      end

      delayed(0.5) {
        exchange.publish(input)
      }

      done(1.0) {
        mailbox.size.should == 1
      }
    end
  end
end