|
172 | 172 | ) |
173 | 173 | end |
174 | 174 |
|
| 175 | + let(:options) do |
| 176 | + Mongo::Options::Redacted.new(:read => { :mode => :primary }, |
| 177 | + :local_threshold_ms => 10, |
| 178 | + :server_selection_timeout_ms => 10000, |
| 179 | + :database => TEST_DB) |
| 180 | + end |
| 181 | + |
175 | 182 | let(:expected) do |
176 | | - [client.cluster, { :read => { :mode => :primary }, |
177 | | - :local_threshold_ms => 10, |
178 | | - :server_selection_timeout_ms => 10000, |
179 | | - :database => TEST_DB }].hash |
| 183 | + [client.cluster, options].hash |
180 | 184 | end |
181 | 185 |
|
182 | 186 | it 'returns a hash of the cluster and options' do |
|
291 | 295 | described_class.new(uri) |
292 | 296 | end |
293 | 297 |
|
| 298 | + let(:expected_options) do |
| 299 | + Mongo::Options::Redacted.new(:write => { :w => 3 }, :database => 'testdb') |
| 300 | + end |
| 301 | + |
294 | 302 | it 'sets the options' do |
295 | | - expect(client.options).to eq(:write => { :w => 3 }, :database => 'testdb') |
| 303 | + expect(client.options).to eq(expected_options) |
296 | 304 | end |
297 | 305 | end |
298 | 306 |
|
|
306 | 314 | described_class.new(uri, :write => { :w => 3 }) |
307 | 315 | end |
308 | 316 |
|
| 317 | + let(:expected_options) do |
| 318 | + Mongo::Options::Redacted.new(:write => { :w => 3 }, :database => 'testdb') |
| 319 | + end |
| 320 | + |
309 | 321 | it 'sets the options' do |
310 | | - expect(client.options).to eq(:write => { :w => 3 }, :database => 'testdb') |
| 322 | + expect(client.options).to eq(expected_options) |
311 | 323 | end |
312 | 324 | end |
313 | 325 |
|
|
321 | 333 | described_class.new(uri, :write => { :w => 4 }) |
322 | 334 | end |
323 | 335 |
|
| 336 | + let(:expected_options) do |
| 337 | + Mongo::Options::Redacted.new(:write => { :w => 4 }, :database => 'testdb') |
| 338 | + end |
| 339 | + |
324 | 340 | it 'allows explicit options to take preference' do |
325 | | - expect(client.options).to eq(:write => { :w => 4 }, :database => 'testdb') |
| 341 | + expect(client.options).to eq(expected_options) |
326 | 342 | end |
327 | 343 | end |
328 | 344 |
|
|
497 | 513 | client.with(:read => { :mode => :primary }) |
498 | 514 | end |
499 | 515 |
|
| 516 | + let(:new_options) do |
| 517 | + Mongo::Options::Redacted.new(:read => { :mode => :primary }, |
| 518 | + :write => { :w => 1 }, |
| 519 | + :database => TEST_DB) |
| 520 | + end |
| 521 | + |
| 522 | + let(:original_options) do |
| 523 | + Mongo::Options::Redacted.new(:read => { :mode => :secondary }, |
| 524 | + :write => { :w => 1 }, |
| 525 | + :database => TEST_DB) |
| 526 | + end |
| 527 | + |
500 | 528 | it 'returns a new client' do |
501 | 529 | expect(new_client).not_to equal(client) |
502 | 530 | end |
503 | 531 |
|
504 | 532 | it 'replaces the existing options' do |
505 | | - expect(new_client.options).to eq({ |
506 | | - :read => { :mode => :primary }, :write => { :w => 1 }, :database => TEST_DB |
507 | | - }) |
| 533 | + expect(new_client.options).to eq(new_options) |
508 | 534 | end |
509 | 535 |
|
510 | 536 | it 'does not modify the original client' do |
511 | | - expect(client.options).to eq({ |
512 | | - :read => { :mode => :secondary }, :write => { :w => 1 }, :database => TEST_DB |
513 | | - }) |
| 537 | + expect(client.options).to eq(original_options) |
514 | 538 | end |
515 | 539 |
|
516 | 540 | it 'keeps the same cluster' do |
|
579 | 603 | end |
580 | 604 |
|
581 | 605 | it 'returns a acknowledged write concern' do |
582 | | - expect(concern.get_last_error).to eq(:getlasterror => 1, :j => true) |
| 606 | + expect(concern.get_last_error).to eq(:getlasterror => 1, 'j' => true) |
583 | 607 | end |
584 | 608 | end |
585 | 609 |
|
|
0 commit comments