Class: Tochtli::Test::TestRabbitConnection
- Inherits:
-
Object
- Object
- Tochtli::Test::TestRabbitConnection
- Defined in:
- lib/tochtli/test/test_case.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#publications ⇒ Object
readonly
Returns the value of attribute publications.
Instance Method Summary collapse
- #callback(&block) ⇒ Object
- #create_channel(consumer_pool_size = 1) ⇒ Object
- #exchange_name ⇒ Object
- #get_publication ⇒ Object
-
#initialize ⇒ TestRabbitConnection
constructor
A new instance of TestRabbitConnection.
- #logger ⇒ Object
- #publish(routing_key, message, options = {}) ⇒ Object
- #queue(name = nil, routing_keys = [], options = {}) ⇒ Object
- #queue_exists?(name) ⇒ Boolean
- #reply_queue ⇒ Object
- #run_callback ⇒ Object
Constructor Details
#initialize ⇒ TestRabbitConnection
Returns a new instance of TestRabbitConnection.
36 37 38 39 40 41 |
# File 'lib/tochtli/test/test_case.rb', line 36 def initialize @channel = TestRabbitChannel.new(self) @exchange = TestRabbitExchange.new @publications = [] @queues = {} end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
34 35 36 |
# File 'lib/tochtli/test/test_case.rb', line 34 def channel @channel end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
34 35 36 |
# File 'lib/tochtli/test/test_case.rb', line 34 def exchange @exchange end |
#publications ⇒ Object (readonly)
Returns the value of attribute publications.
34 35 36 |
# File 'lib/tochtli/test/test_case.rb', line 34 def publications @publications end |
Instance Method Details
#callback(&block) ⇒ Object
60 61 62 |
# File 'lib/tochtli/test/test_case.rb', line 60 def callback(&block) @callback = block end |
#create_channel(consumer_pool_size = 1) ⇒ Object
87 88 89 |
# File 'lib/tochtli/test/test_case.rb', line 87 def create_channel(consumer_pool_size = 1) TestRabbitChannel.new(self) end |
#exchange_name ⇒ Object
43 44 45 |
# File 'lib/tochtli/test/test_case.rb', line 43 def exchange_name @exchange.name end |
#get_publication ⇒ Object
56 57 58 |
# File 'lib/tochtli/test/test_case.rb', line 56 def get_publication @publications.shift end |
#logger ⇒ Object
71 72 73 |
# File 'lib/tochtli/test/test_case.rb', line 71 def logger Logger.new(STDOUT) end |
#publish(routing_key, message, options = {}) ⇒ Object
51 52 53 54 |
# File 'lib/tochtli/test/test_case.rb', line 51 def publish(routing_key, , ={}) @publications << .merge(routing_key: routing_key, message: ) run_callback end |
#queue(name = nil, routing_keys = [], options = {}) ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/tochtli/test/test_case.rb', line 75 def queue(name=nil, routing_keys=[], ={}) queue = @queues[name] unless queue @queues[name] = queue = TestQueue.new(@channel, name, ) end queue end |
#queue_exists?(name) ⇒ Boolean
83 84 85 |
# File 'lib/tochtli/test/test_case.rb', line 83 def queue_exists?(name) @queues.has_key?(name) end |
#reply_queue ⇒ Object
47 48 49 |
# File 'lib/tochtli/test/test_case.rb', line 47 def reply_queue @reply_queue ||= Tochtli::ReplyQueue.new(self) end |
#run_callback ⇒ Object
64 65 66 67 68 69 |
# File 'lib/tochtli/test/test_case.rb', line 64 def run_callback if @callback @callback.call @callback = nil end end |