Class: AmqpSpecHelper::QueueMock

Inherits:
Object
  • Object
show all
Defined in:
lib/onapp/engine/spec/amqp_helper.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (QueueMock) initialize(name, channel)

Returns a new instance of QueueMock



18
19
20
21
22
# File 'lib/onapp/engine/spec/amqp_helper.rb', line 18

def initialize(name, channel)
  @name = name
  @channel = channel
  @subscriptions = []
end

Instance Attribute Details

- (Object) name

Returns the value of attribute name



16
17
18
# File 'lib/onapp/engine/spec/amqp_helper.rb', line 16

def name
  @name
end

Instance Method Details

- (Object) bind(exchange, routing_key: nil)



36
37
38
39
40
41
# File 'lib/onapp/engine/spec/amqp_helper.rb', line 36

def bind(exchange, routing_key: nil)
  if exchange.is_a?(FanoutExchange)
    exchange.bound_queues << self
  end
  self
end

- (Object) publish(message = nil, meta: metadata())



28
29
30
# File 'lib/onapp/engine/spec/amqp_helper.rb', line 28

def publish(message = nil, meta: ())
  @subscriptions.each { |s| s.call(meta, message) }
end

- (Object) status {|@channel.default_exchange.messages[@name.to_s].count, 0| ... }

Yields:

  • (@channel.default_exchange.messages[@name.to_s].count, 0)


32
33
34
# File 'lib/onapp/engine/spec/amqp_helper.rb', line 32

def status
  yield @channel.default_exchange.messages[@name.to_s].count, 0
end

- (Object) subscribe(opts = {}, &block)



24
25
26
# File 'lib/onapp/engine/spec/amqp_helper.rb', line 24

def subscribe(opts = {}, &block)
  @subscriptions << block
end