|
104 | 104 | exchange = Object.new |
105 | 105 | existing_session = Bunny.new |
106 | 106 |
|
107 | | - mock(existing_session).start { existing_session } |
| 107 | + mock(existing_session).start |
108 | 108 | mock(existing_session).create_channel { channel } |
109 | 109 |
|
110 | 110 | mock(channel).exchange('another_exchange', type: :topic, durable: false, :auto_delete => false, arguments: { 'x-arg' => 'value' }) do |
|
122 | 122 | durable: false |
123 | 123 | ) |
124 | 124 | @existing_session = existing_session |
| 125 | + @exchange = exchange |
| 126 | + @channel = channel |
125 | 127 | end |
126 | 128 |
|
127 | 129 | it 'can handle an existing connection object' do |
|
136 | 138 | p.publish('test msg', my_vars) |
137 | 139 | _(p.instance_variable_get(:@bunny)).must_equal @existing_session |
138 | 140 | end |
| 141 | + |
| 142 | + it 'can handle an existing connection that is online' do |
| 143 | + p = Sneakers::Publisher.new |
| 144 | + p.publish('test msg', my_vars) |
| 145 | + _(p.instance_variable_get(:@bunny)).must_equal @existing_session |
| 146 | + mock(@existing_session).connected? { true } |
| 147 | + mock(@exchange).publish('test msg 2', my_vars) |
| 148 | + p.publish('test msg 2', my_vars) |
| 149 | + end |
| 150 | + |
| 151 | + it 'can handle an existing connection that goes offline' do |
| 152 | + p = Sneakers::Publisher.new |
| 153 | + p.publish('test msg', my_vars) |
| 154 | + _(p.instance_variable_get(:@bunny)).must_equal @existing_session |
| 155 | + mock(@existing_session).connected? { false } |
| 156 | + mock(@existing_session).start |
| 157 | + mock(@existing_session).create_channel { @channel } |
| 158 | + mock(@channel).exchange('another_exchange', type: :topic, durable: false, :auto_delete => false, arguments: { 'x-arg' => 'value' }) do |
| 159 | + @exchange |
| 160 | + end |
| 161 | + mock(@exchange).publish('test msg 2', my_vars) |
| 162 | + p.publish('test msg 2', my_vars) |
| 163 | + end |
139 | 164 | end |
140 | 165 |
|
141 | 166 | it 'should publish using the content type serializer' do |
|
0 commit comments