File: remove_individual_binding_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 (51 lines) | stat: -rw-r--r-- 1,084 bytes parent folder | download | duplicates (2)
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
# encoding: utf-8

require 'spec_helper'

describe "An individual binding" do

  #
  # Environment
  #

  include EventedSpec::AMQPSpec

  default_timeout 3

  amqp_before do
    @channel   = AMQP::Channel.new
    @channel.should be_open
    @channel.on_error do |ch, close|
      raise "Channel-level error!: #{close.inspect}"
    end
  end


  default_options AMQP_OPTS


  it "can be deleted by specifying routing key" do
    flag1 = false
    flag2 = false

    x  = @channel.direct("amqpgem.examples.imaging")

    q = @channel.queue("", :exclusive => true)
    q.bind(x, :routing_key => "resize").bind(x, :routing_key => "watermark").subscribe do |meta, payload|
      flag1 = (meta.routing_key == "watermark")
      flag2 = (meta.routing_key == "resize")
    end

    EventMachine.add_timer(0.5) do
      q.unbind(x, :routing_key => "resize") do
        x.publish("some data", :routing_key => "resize")
        x.publish("some data", :routing_key => "watermark")
      end

      done(1.0) {
        flag1.should be_true
        flag2.should be_false
      }
    end
  end
end