|
2 | 2 |
|
3 | 3 | describe Mongo::Cluster do
|
4 | 4 |
|
5 |
| - describe '#==' do |
| 5 | + let(:cluster) do |
| 6 | + described_class.new(ADDRESSES) |
| 7 | + end |
6 | 8 |
|
7 |
| - let(:cluster) do |
8 |
| - described_class.new([ '127.0.0.1:27017' ]) |
9 |
| - end |
| 9 | + describe '#==' do |
10 | 10 |
|
11 | 11 | context 'when the other is a cluster' do
|
12 | 12 |
|
|
61 | 61 | Mongo::ServerSelector.get
|
62 | 62 | end
|
63 | 63 |
|
64 |
| - let(:cluster) do |
65 |
| - described_class.new([ '127.0.0.1:27017' ]) |
66 |
| - end |
67 |
| - |
68 | 64 | it 'displays the cluster seeds and topology' do
|
69 | 65 | expect(cluster.inspect).to include('topology')
|
70 | 66 | expect(cluster.inspect).to include('servers')
|
|
78 | 74 | end
|
79 | 75 |
|
80 | 76 | let(:cluster) do
|
81 |
| - described_class.new([ '127.0.0.1:27017' ], :replica_set => 'testing') |
| 77 | + described_class.new(ADDRESSES, :replica_set => 'testing') |
82 | 78 | end
|
83 | 79 |
|
84 | 80 | context 'when the option is provided' do
|
85 | 81 |
|
86 | 82 | let(:cluster) do
|
87 |
| - described_class.new([ '127.0.0.1:27017' ], :replica_set => 'testing') |
| 83 | + described_class.new(ADDRESSES, :replica_set => 'testing') |
88 | 84 | end
|
89 | 85 |
|
90 | 86 | it 'returns the name' do
|
|
95 | 91 | context 'when the option is not provided' do
|
96 | 92 |
|
97 | 93 | let(:cluster) do
|
98 |
| - described_class.new([ '127.0.0.1:27017' ]) |
| 94 | + described_class.new(ADDRESSES) |
99 | 95 | end
|
100 | 96 |
|
101 | 97 | it 'returns nil' do
|
|
110 | 106 | Mongo::ServerSelector.get
|
111 | 107 | end
|
112 | 108 |
|
113 |
| - let(:cluster) do |
114 |
| - described_class.new([ '127.0.0.1:27017' ]) |
115 |
| - end |
116 |
| - |
117 | 109 | let(:known_servers) do
|
118 | 110 | cluster.instance_variable_get(:@servers)
|
119 | 111 | end
|
|
131 | 123 |
|
132 | 124 | context 'when topology is single', if: single_seed? do
|
133 | 125 |
|
134 |
| - let(:cluster) do |
135 |
| - described_class.new(ADDRESSES) |
136 |
| - end |
137 |
| - |
138 | 126 | context 'when the server is a mongos', if: single_mongos? do
|
139 | 127 |
|
140 | 128 | it 'returns the mongos' do
|
|
152 | 140 |
|
153 | 141 | context 'when the cluster has no servers' do
|
154 | 142 |
|
155 |
| - let(:cluster) do |
156 |
| - described_class.new(ADDRESSES) |
157 |
| - end |
158 |
| - |
159 | 143 | let(:servers) do
|
160 | 144 | [nil]
|
161 | 145 | end
|
|
210 | 194 | end
|
211 | 195 | end
|
212 | 196 | end
|
| 197 | + |
| 198 | + describe '#add' do |
| 199 | + |
| 200 | + context 'when topology is Single' do |
| 201 | + |
| 202 | + let(:topology) do |
| 203 | + Mongo::Cluster::Topology::Single.new({}) |
| 204 | + end |
| 205 | + |
| 206 | + before do |
| 207 | + cluster.add('a') |
| 208 | + end |
| 209 | + |
| 210 | + it 'does not add discovered servers to the cluster' do |
| 211 | + expect(cluster.servers[0].address.seed).to_not eq('a') |
| 212 | + end |
| 213 | + end |
| 214 | + end |
213 | 215 | end
|
0 commit comments