|
36 | 36 | context "when the configuration exists" do
|
37 | 37 |
|
38 | 38 | context "when the configuration is standard" do
|
| 39 | + restore_config_clients |
39 | 40 |
|
40 | 41 | let(:config) do
|
41 | 42 | {
|
|
46 | 47 |
|
47 | 48 | before do
|
48 | 49 | Mongoid::Config.send(:clients=, config)
|
49 |
| - # TODO: We should restore overwritten configuration in after block |
50 | 50 | end
|
51 | 51 |
|
52 | 52 | after do
|
|
118 | 118 | end
|
119 | 119 |
|
120 | 120 | context "when the configuration has no ports" do
|
| 121 | + restore_config_clients |
121 | 122 |
|
122 | 123 | let(:config) do
|
123 | 124 | {
|
|
128 | 129 |
|
129 | 130 | before do
|
130 | 131 | Mongoid::Config.send(:clients=, config)
|
131 |
| - # TODO: We should restore overwritten configuration in after block |
132 | 132 | end
|
133 | 133 |
|
134 | 134 | after do
|
|
163 | 163 | context "when configured via a uri" do
|
164 | 164 |
|
165 | 165 | context "when the uri has a single host:port" do
|
| 166 | + restore_config_clients |
166 | 167 |
|
167 | 168 | let(:config) do
|
168 | 169 | {
|
|
173 | 174 |
|
174 | 175 | before do
|
175 | 176 | Mongoid::Config.send(:clients=, config)
|
176 |
| - # TODO: We should restore overwritten configuration in after block |
177 | 177 | end
|
178 | 178 |
|
179 | 179 | after do
|
|
202 | 202 | end
|
203 | 203 |
|
204 | 204 | context "when the uri has multiple host:port pairs" do
|
| 205 | + restore_config_clients |
205 | 206 |
|
206 | 207 | let(:config) do
|
207 | 208 | {
|
|
212 | 213 |
|
213 | 214 | before do
|
214 | 215 | Mongoid::Config.send(:clients=, config)
|
215 |
| - # TODO: We should restore overwritten configuration in after block |
216 | 216 | end
|
217 | 217 |
|
218 | 218 | after do
|
|
253 | 253 | end
|
254 | 254 |
|
255 | 255 | context "when no name is provided" do
|
| 256 | + restore_config_clients |
256 | 257 |
|
257 | 258 | let(:config) do
|
258 | 259 | { default: { hosts: SpecConfig.instance.addresses, database: database_id }}
|
259 | 260 | end
|
260 | 261 |
|
261 | 262 | before do
|
262 | 263 | Mongoid::Config.send(:clients=, config)
|
263 |
| - # TODO: We should restore overwritten configuration in after block |
264 | 264 | end
|
265 | 265 |
|
266 | 266 | after do
|
|
287 | 287 | end
|
288 | 288 |
|
289 | 289 | context "when nil is provided and no default config" do
|
| 290 | + restore_config_clients |
290 | 291 |
|
291 | 292 | let(:config) { nil }
|
292 | 293 |
|
293 | 294 | before do
|
294 | 295 | Mongoid.clients[:default] = nil
|
295 |
| - # TODO: We should restore overwritten configuration in after block |
296 | 296 | end
|
297 | 297 |
|
298 | 298 | it "raises NoClientsConfig error" do
|
|
302 | 302 | end
|
303 | 303 |
|
304 | 304 | describe ".default" do
|
| 305 | + restore_config_clients |
305 | 306 |
|
306 | 307 | let(:config) do
|
307 | 308 | { default: { hosts: SpecConfig.instance.addresses, database: database_id }}
|
308 | 309 | end
|
309 | 310 |
|
310 | 311 | before do
|
311 | 312 | Mongoid::Config.send(:clients=, config)
|
312 |
| - # TODO: We should restore overwritten configuration in after block |
313 | 313 | end
|
314 | 314 |
|
315 | 315 | after do
|
|
336 | 336 | end
|
337 | 337 |
|
338 | 338 | context "when options are provided with string keys" do
|
| 339 | + restore_config_clients |
339 | 340 |
|
340 | 341 | let(:config) do
|
341 | 342 | {
|
|
352 | 353 |
|
353 | 354 | before do
|
354 | 355 | Mongoid::Config.send(:clients=, config)
|
355 |
| - # TODO: We should restore overwritten configuration in after block |
356 | 356 | end
|
357 | 357 |
|
358 | 358 | after do
|
|
391 | 391 | end
|
392 | 392 |
|
393 | 393 | context "unexpected config options" do
|
| 394 | + restore_config_clients |
| 395 | + |
394 | 396 | let(:unknown_opts) do
|
395 | 397 | {
|
396 | 398 | bad_one: 1,
|
|
408 | 410 | }
|
409 | 411 | end
|
410 | 412 |
|
411 |
| - around(:each) do |example| |
412 |
| - old_config = Mongoid::Config.clients |
| 413 | + before do |
413 | 414 | Mongoid::Config.send(:clients=, config)
|
414 |
| - example.run |
415 |
| - Mongoid::Config.send(:clients=, old_config) |
416 | 415 | end
|
417 | 416 |
|
418 | 417 | [:bad_one, :bad_two].each do |env|
|
|
0 commit comments