|
6 | 6 |
|
7 | 7 | describe Cony::AMQPConnection do |
8 | 8 | let(:amqp_config) { { exchange: 'bunny-tests' } } |
9 | | - let(:config) { double('Cony Config', amqp: amqp_config, durable: false) } |
| 9 | + let(:config) { double('Cony Config', amqp: amqp_config, durable: false, amqp_connection: nil) } |
10 | 10 | let(:handler) { Cony::AMQPConnection } |
11 | 11 | let(:message) { 'Bunnies are connies' } |
12 | 12 | let(:routing_key) { 'bunny.info' } |
|
93 | 93 | describe 'setting a connection' do |
94 | 94 | let(:existing_connection) { connection_double.clone } |
95 | 95 |
|
96 | | - it 'sets the connection to the given one' do |
97 | | - subject.instance.connection = existing_connection |
| 96 | + describe 'on the AmqpConnection (deprecated)' do |
| 97 | + it 'sets the connection to the given one' do |
| 98 | + subject.instance.connection = existing_connection |
98 | 99 |
|
99 | | - expect(subject.instance.connection).to be(existing_connection) |
| 100 | + expect(subject.instance.connection).to be(existing_connection) |
| 101 | + end |
| 102 | + |
| 103 | + it 'raises exception when redefining the connection' do |
| 104 | + expect(subject.instance.connection).to be(connection_double) |
| 105 | + expect { subject.instance.connection = existing_connection }. |
| 106 | + to raise_error(Cony::ValidConnectionAlreadyDefined) |
| 107 | + end |
100 | 108 | end |
101 | 109 |
|
102 | | - it 'raises exception when redefining the connection' do |
103 | | - expect(subject.instance.connection).to be(connection_double) |
104 | | - expect { subject.instance.connection = existing_connection }. |
105 | | - to raise_error(Cony::ValidConnectionAlreadyDefined) |
| 110 | + describe 'through the config' do |
| 111 | + let(:config) do |
| 112 | + double('Cony Config', amqp: amqp_config, durable: false, amqp_connection: existing_connection) |
| 113 | + end |
| 114 | + |
| 115 | + it 'uses the connection from the config' do |
| 116 | + expect(subject.instance.connection).to be(existing_connection) |
| 117 | + end |
| 118 | + |
| 119 | + it 'raises exception when redefining the connection' do |
| 120 | + expect(subject.instance.connection).to be(existing_connection) |
| 121 | + expect { subject.instance.connection = existing_connection }. |
| 122 | + to raise_error(Cony::ValidConnectionAlreadyDefined) |
| 123 | + end |
| 124 | + |
| 125 | + describe 'no amqp config hash given' do |
| 126 | + let(:config) do |
| 127 | + double('Cony Config', amqp: nil, durable: false, amqp_connection: existing_connection) |
| 128 | + end |
| 129 | + |
| 130 | + it 'still uses the connection from the config' do |
| 131 | + expect(subject.instance.connection).to be(existing_connection) |
| 132 | + end |
| 133 | + end |
106 | 134 | end |
107 | 135 | end |
108 | 136 | end |
0 commit comments