|
12 | 12 | ClientRegistry.instance.close_all_clients |
13 | 13 | end |
14 | 14 |
|
| 15 | + let(:client) do |
| 16 | + new_local_client(string, monitoring_io: false) |
| 17 | + end |
| 18 | + |
15 | 19 | describe 'invalid uris' do |
16 | 20 |
|
17 | 21 | context 'when there is more than one hostname' do |
|
353 | 357 | end |
354 | 358 |
|
355 | 359 | it 'sets the options on a client created with the uri' do |
356 | | - expect(new_local_client(string).options[:write]).to eq(concern) |
| 360 | + expect(client.options[:write]).to eq(concern) |
357 | 361 | end |
358 | 362 | end |
359 | 363 |
|
|
366 | 370 | end |
367 | 371 |
|
368 | 372 | it 'sets the options on a client created with the uri' do |
369 | | - expect(new_local_client(string).options[:write]).to eq(concern) |
| 373 | + expect(client.options[:write]).to eq(concern) |
370 | 374 | end |
371 | 375 | end |
372 | 376 |
|
|
379 | 383 | end |
380 | 384 |
|
381 | 385 | it 'sets the options on a client created with the uri' do |
382 | | - expect(new_local_client(string).options[:write]).to eq(concern) |
| 386 | + expect(client.options[:write]).to eq(concern) |
383 | 387 | end |
384 | 388 | end |
385 | 389 |
|
|
392 | 396 | end |
393 | 397 |
|
394 | 398 | it 'sets the options on a client created with the uri' do |
395 | | - expect(new_local_client(string).options[:write]).to eq(concern) |
| 399 | + expect(client.options[:write]).to eq(concern) |
396 | 400 | end |
397 | 401 | end |
398 | 402 |
|
|
406 | 410 | end |
407 | 411 |
|
408 | 412 | it 'sets the options on a client created with the uri' do |
409 | | - expect(new_local_client(string).options[:write]).to eq(concern) |
| 413 | + expect(client.options[:write]).to eq(concern) |
410 | 414 | end |
411 | 415 | end |
412 | 416 | end |
|
423 | 427 | end |
424 | 428 |
|
425 | 429 | it 'sets the options on a client created with the uri' do |
426 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 430 | + expect(client.options[:read]).to eq(read) |
427 | 431 | end |
428 | 432 | end |
429 | 433 |
|
|
436 | 440 | end |
437 | 441 |
|
438 | 442 | it 'sets the options on a client created with the uri' do |
439 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 443 | + expect(client.options[:read]).to eq(read) |
440 | 444 | end |
441 | 445 | end |
442 | 446 |
|
|
449 | 453 | end |
450 | 454 |
|
451 | 455 | it 'sets the options on a client created with the uri' do |
452 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 456 | + expect(client.options[:read]).to eq(read) |
453 | 457 | end |
454 | 458 | end |
455 | 459 |
|
|
462 | 466 | end |
463 | 467 |
|
464 | 468 | it 'sets the options on a client created with the uri' do |
465 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 469 | + expect(client.options[:read]).to eq(read) |
466 | 470 | end |
467 | 471 | end |
468 | 472 |
|
|
475 | 479 | end |
476 | 480 |
|
477 | 481 | it 'sets the options on a client created with the uri' do |
478 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 482 | + expect(client.options[:read]).to eq(read) |
479 | 483 | end |
480 | 484 | end |
481 | 485 | end |
|
496 | 500 | end |
497 | 501 |
|
498 | 502 | it 'sets the options on a client created with the uri' do |
499 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 503 | + expect(client.options[:read]).to eq(read) |
500 | 504 | end |
501 | 505 | end |
502 | 506 |
|
|
514 | 518 | end |
515 | 519 |
|
516 | 520 | it 'sets the options on a client created with the uri' do |
517 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 521 | + expect(client.options[:read]).to eq(read) |
518 | 522 | end |
519 | 523 | end |
520 | 524 | end |
|
534 | 538 | end |
535 | 539 |
|
536 | 540 | it 'sets the options on a client created with the uri' do |
537 | | - expect(new_local_client(string).options[:read]).to eq(read) |
| 541 | + expect(client.options[:read]).to eq(read) |
538 | 542 | end |
539 | 543 |
|
540 | 544 | context 'when the read preference and max staleness combination is invalid' do |
|
547 | 551 |
|
548 | 552 | it 'raises an exception when read preference is accessed on the client' do |
549 | 553 | expect { |
550 | | - new_local_client(string).server_selector |
| 554 | + client.server_selector |
551 | 555 | }.to raise_exception(Mongo::Error::InvalidServerPreference) |
552 | 556 | end |
553 | 557 | end |
|
559 | 563 | end |
560 | 564 |
|
561 | 565 | it 'does not raise an exception until the read preference is used' do |
562 | | - expect(new_local_client(string).read_preference).to eq(BSON::Document.new(mode: :secondary, max_staleness: 89)) |
| 566 | + expect(client.read_preference).to eq(BSON::Document.new(mode: :secondary, max_staleness: 89)) |
563 | 567 | end |
564 | 568 | end |
565 | 569 | end |
|
574 | 578 | end |
575 | 579 |
|
576 | 580 | it 'sets the options on a client created with the uri' do |
577 | | - expect(new_local_client(string).options[:replica_set]).to eq(rs_name) |
| 581 | + expect(client.options[:replica_set]).to eq(rs_name) |
578 | 582 | end |
579 | 583 | end |
580 | 584 |
|
|
590 | 594 | end |
591 | 595 |
|
592 | 596 | it 'sets the options on a client created with the uri' do |
593 | | - expect(new_local_client(string).options[:auth_mech]).to eq(expected) |
| 597 | + expect(client.options[:auth_mech]).to eq(expected) |
594 | 598 | end |
595 | 599 |
|
596 | 600 | it 'is case-insensitive' do |
|
607 | 611 | end |
608 | 612 |
|
609 | 613 | it 'sets the options on a client created with the uri' do |
610 | | - expect(new_local_client(string).options[:auth_mech]).to eq(expected) |
| 614 | + expect(client.options[:auth_mech]).to eq(expected) |
611 | 615 | end |
612 | 616 |
|
613 | 617 | it 'is case-insensitive' do |
|
624 | 628 | end |
625 | 629 |
|
626 | 630 | it 'sets the options on a client created with the uri' do |
627 | | - expect(new_local_client(string).options[:auth_mech]).to eq(expected) |
| 631 | + expect(client.options[:auth_mech]).to eq(expected) |
628 | 632 | end |
629 | 633 |
|
630 | 634 | it 'is case-insensitive' do |
|
641 | 645 | end |
642 | 646 |
|
643 | 647 | it 'sets the options on a client created with the uri' do |
644 | | - expect(new_local_client(string).options[:auth_mech]).to eq(expected) |
| 648 | + expect(client.options[:auth_mech]).to eq(expected) |
645 | 649 | end |
646 | 650 |
|
647 | 651 | it 'is case-insensitive' do |
|
658 | 662 | end |
659 | 663 |
|
660 | 664 | it 'sets the options on a client created with the uri' do |
661 | | - expect(new_local_client(string).options[:auth_mech]).to eq(expected) |
| 665 | + expect(client.options[:auth_mech]).to eq(expected) |
662 | 666 | end |
663 | 667 |
|
664 | 668 | it 'is case-insensitive' do |
|
686 | 690 | end |
687 | 691 |
|
688 | 692 | it 'sets the options on a client created with the uri' do |
689 | | - expect(new_local_client(string).options[:auth_source]).to eq(source) |
| 693 | + expect(client.options[:auth_source]).to eq(source) |
690 | 694 | end |
691 | 695 | end |
692 | 696 |
|
|
699 | 703 | end |
700 | 704 |
|
701 | 705 | it 'sets the options on a client created with the uri' do |
702 | | - expect(new_local_client(string).options[:auth_source]).to eq(expected) |
| 706 | + expect(client.options[:auth_source]).to eq(expected) |
703 | 707 | end |
704 | 708 | end |
705 | 709 | end |
|
719 | 723 | end |
720 | 724 |
|
721 | 725 | it 'sets the options on a client created with the uri' do |
722 | | - expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected) |
| 726 | + expect(client.options[:auth_mech_properties]).to eq(expected) |
723 | 727 | end |
724 | 728 | end |
725 | 729 |
|
|
735 | 739 | end |
736 | 740 |
|
737 | 741 | it 'sets the options on a client created with the uri' do |
738 | | - expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected) |
| 742 | + expect(client.options[:auth_mech_properties]).to eq(expected) |
739 | 743 | end |
740 | 744 | end |
741 | 745 |
|
|
753 | 757 | end |
754 | 758 |
|
755 | 759 | it 'sets the options on a client created with the uri' do |
756 | | - expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected) |
| 760 | + expect(client.options[:auth_mech_properties]).to eq(expected) |
757 | 761 | end |
758 | 762 | end |
759 | 763 |
|
|
779 | 783 | end |
780 | 784 |
|
781 | 785 | it 'sets the options on a client created with the uri' do |
782 | | - expect(new_local_client(string).options[:auth_mech_properties]).to eq(expected) |
| 786 | + expect(client.options[:auth_mech_properties]).to eq(expected) |
783 | 787 | end |
784 | 788 | end |
785 | 789 | end |
|
907 | 911 | let(:options) { "appname=srv_test" } |
908 | 912 |
|
909 | 913 | it 'sets the app name on the client' do |
910 | | - expect(new_local_client(string).options[:app_name]).to eq(:srv_test) |
| 914 | + expect(client.options[:app_name]).to eq(:srv_test) |
911 | 915 | end |
912 | 916 | end |
913 | 917 |
|
914 | 918 | context 'when a supported compressors option is provided' do |
915 | 919 | let(:options) { "compressors=zlib" } |
916 | 920 |
|
917 | 921 | it 'sets the compressors as an array on the client' do |
918 | | - expect(new_local_client(string).options[:compressors]).to eq(['zlib']) |
| 922 | + expect(client.options[:compressors]).to eq(['zlib']) |
919 | 923 | end |
920 | 924 | end |
921 | 925 |
|
922 | 926 | context 'when a non-supported compressors option is provided' do |
923 | 927 | let(:options) { "compressors=snoopy" } |
924 | 928 |
|
925 | | - let(:client) do |
926 | | - new_local_client(string) |
927 | | - end |
928 | | - |
929 | 929 | it 'sets no compressors on the client and warns' do |
930 | 930 | expect(Mongo::Logger.logger).to receive(:warn) |
931 | 931 | expect(client.options[:compressors]).to be_nil |
|
936 | 936 | let(:options) { "zlibCompressionLevel=6" } |
937 | 937 |
|
938 | 938 | it 'sets the zlib compression level on the client' do |
939 | | - expect(new_local_client(string).options[:zlib_compression_level]).to eq(6) |
| 939 | + expect(client.options[:zlib_compression_level]).to eq(6) |
940 | 940 | end |
941 | 941 | end |
942 | 942 | end |
|
0 commit comments