|
505 | 505 |
|
506 | 506 | it "body is a standard hash" do |
507 | 507 | expect(response_body).to be_a(Hash) |
508 | | - end |
509 | | - |
510 | | - it "body is not a SnakyHash" do |
511 | | - expect(response_body).not_to be_a(SnakyHash) |
| 508 | + expect(response_body).not_to be_a(SnakyHash::StringKeyed) |
| 509 | + expect(response_body).not_to be_a(SnakyHash::SymbolKeyed) |
512 | 510 | end |
513 | 511 | end |
514 | 512 | end |
|
582 | 580 |
|
583 | 581 | context "when snaky" do |
584 | 582 | subject(:token) do |
585 | | - client = stubbed_client do |stub| |
| 583 | + client = stubbed_client(options) do |stub| |
586 | 584 | stub.post("/oauth/token") do |
587 | 585 | [200, {"Content-Type" => "application/json"}, response_body] |
588 | 586 | end |
|
591 | 589 | client.get_token(params, access_token_opts) |
592 | 590 | end |
593 | 591 |
|
| 592 | + let(:options) { {raise_errors: false} } |
594 | 593 | let(:access_token_opts) { {} } |
595 | 594 | let(:response_body) { JSON.dump("access_token" => "the-token") } |
596 | 595 |
|
|
609 | 608 | expect(token).to be_a OAuth2::AccessToken |
610 | 609 | expect(token.token).to eq("the-token") |
611 | 610 | expect(token.response.parsed).to be_a(Hash) |
612 | | - end |
613 | | - |
614 | | - it "parsed is not a SnakyHash" do |
615 | | - expect(token).to be_a OAuth2::AccessToken |
616 | | - expect(token.token).to eq("the-token") |
617 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 611 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 612 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
618 | 613 | end |
619 | 614 | end |
620 | 615 |
|
|
631 | 626 | expect(token).to be_a OAuth2::AccessToken |
632 | 627 | expect(token.token).to eq("the-token") |
633 | 628 | expect(token.response.parsed).to be_a(Hash) |
634 | | - end |
635 | | - |
636 | | - it "parsed is not a SnakyHash" do |
637 | | - expect(token).to be_a OAuth2::AccessToken |
638 | | - expect(token.token).to eq("the-token") |
639 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 629 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 630 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
640 | 631 | end |
641 | 632 |
|
642 | 633 | context "with alternate token named" do |
|
647 | 638 | expect(token).to be_a OAuth2::AccessToken |
648 | 639 | expect(token.token).to eq("the-token") |
649 | 640 | expect(token.response.parsed).to be_a(Hash) |
650 | | - end |
651 | | - |
652 | | - it "parsed is not a SnakyHash" do |
653 | | - expect(token).to be_a OAuth2::AccessToken |
654 | | - expect(token.token).to eq("the-token") |
655 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 641 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 642 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
656 | 643 | end |
657 | 644 |
|
658 | 645 | it "returns a snake-cased key" do |
|
673 | 660 | expect(token).to be_a OAuth2::AccessToken |
674 | 661 | expect(token.token).to eq("the-token") |
675 | 662 | expect(token.response.parsed).to be_a(Hash) |
676 | | - end |
677 | | - |
678 | | - it "parsed is not a SnakyHash" do |
679 | | - expect(token).to be_a OAuth2::AccessToken |
680 | | - expect(token.token).to eq("the-token") |
681 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 663 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 664 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
682 | 665 | end |
683 | 666 |
|
684 | 667 | it "returns a configured AccessToken" do |
|
701 | 684 | expect(token).to be_a OAuth2::AccessToken |
702 | 685 | expect(token.token).to eq("the-token") |
703 | 686 | expect(token.response.parsed).to be_a(Hash) |
| 687 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 688 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
704 | 689 | end |
705 | 690 |
|
706 | | - it "parsed is not a SnakyHash" do |
707 | | - expect(token).to be_a OAuth2::AccessToken |
708 | | - expect(token.token).to eq("the-token") |
709 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
710 | | - end |
711 | | - |
712 | | - context "with alternate token named" do |
| 691 | + context "with alternate token name" do |
713 | 692 | let(:access_token_opts) { {token_name: "bananaFace"} } |
714 | 693 | let(:response_body) { JSON.dump("bananaFace" => "the-token") } |
715 | 694 |
|
716 | 695 | it "parsed is a Hash" do |
717 | 696 | expect(token).to be_a OAuth2::AccessToken |
718 | 697 | expect(token.token).to eq("the-token") |
719 | 698 | expect(token.response.parsed).to be_a(Hash) |
720 | | - end |
721 | | - |
722 | | - it "parsed is not a SnakyHash" do |
723 | | - expect(token).to be_a OAuth2::AccessToken |
724 | | - expect(token.token).to eq("the-token") |
725 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 699 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 700 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
726 | 701 | end |
727 | 702 |
|
728 | 703 | it "returns a snake-cased key" do |
|
746 | 721 | expect(token).to be_a OAuth2::AccessToken |
747 | 722 | expect(token.token).to eq("the-token") |
748 | 723 | expect(token.response.parsed).to be_a(Hash) |
749 | | - end |
750 | | - |
751 | | - it "parsed is not a SnakyHash" do |
752 | | - expect(token).to be_a OAuth2::AccessToken |
753 | | - expect(token.token).to eq("the-token") |
754 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 724 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 725 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
755 | 726 | end |
756 | 727 |
|
757 | 728 | it "returns a snake-cased key" do |
|
768 | 739 | expect(token).to be_a OAuth2::AccessToken |
769 | 740 | expect(token.token).to eq("the-token") |
770 | 741 | expect(token.response.parsed).to be_a(Hash) |
771 | | - end |
772 | | - |
773 | | - it "parsed is not a SnakyHash" do |
774 | | - expect(token).to be_a OAuth2::AccessToken |
775 | | - expect(token.token).to eq("the-token") |
776 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 742 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 743 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
777 | 744 | end |
778 | 745 |
|
779 | 746 | it "returns a snake-cased key" do |
|
795 | 762 | expect(token).to be_a OAuth2::AccessToken |
796 | 763 | expect(token.token).to eq("the-token") |
797 | 764 | expect(token.response.parsed).to be_a(Hash) |
798 | | - end |
799 | | - |
800 | | - it "parsed is not a SnakyHash" do |
801 | | - expect(token).to be_a OAuth2::AccessToken |
802 | | - expect(token.token).to eq("the-token") |
803 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 765 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 766 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
804 | 767 | end |
805 | 768 | end |
806 | 769 | end |
|
811 | 774 | context "with token_name" do |
812 | 775 | let(:access_token_opts) { {token_name: "accessToken"} } |
813 | 776 |
|
814 | | - it "raises an Error because snaky has renamed the key" do |
815 | | - block_is_expected.to raise_error(OAuth2::Error) |
| 777 | + it "parsed is a Hash, but no token since snaky changed key" do |
| 778 | + expect(token).to be_a OAuth2::AccessToken |
| 779 | + expect(token.token).to eq("") |
| 780 | + expect(token.response.parsed).to be_a(Hash) |
| 781 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 782 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
| 783 | + end |
| 784 | + |
| 785 | + it "returns a snake-cased key" do |
| 786 | + expect(token).to be_a OAuth2::AccessToken |
| 787 | + expect(token.response.parsed.to_h).to eq("access_token" => "the-token") |
816 | 788 | end |
817 | 789 |
|
818 | 790 | context "with alternate snaky token named" do |
|
823 | 795 | expect(token).to be_a OAuth2::AccessToken |
824 | 796 | expect(token.token).to eq("the-token") |
825 | 797 | expect(token.response.parsed).to be_a(Hash) |
826 | | - end |
827 | | - |
828 | | - it "parsed is not a SnakyHash" do |
829 | | - expect(token).to be_a OAuth2::AccessToken |
830 | | - expect(token.token).to eq("the-token") |
831 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 798 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 799 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
832 | 800 | end |
833 | 801 |
|
834 | 802 | it "returns a snake-cased key" do |
|
844 | 812 | expect(token).to be_a OAuth2::AccessToken |
845 | 813 | expect(token.token).to eq("the-token") |
846 | 814 | expect(token.response.parsed).to be_a(Hash) |
847 | | - end |
848 | | - |
849 | | - it "parsed is not a SnakyHash" do |
850 | | - expect(token).to be_a OAuth2::AccessToken |
851 | | - expect(token.token).to eq("the-token") |
852 | | - expect(token.response.parsed).not_to be_a(SnakyHash) |
| 815 | + expect(token.response.parsed).not_to be_a(SnakyHash::StringKeyed) |
| 816 | + expect(token.response.parsed).not_to be_a(SnakyHash::SymbolKeyed) |
853 | 817 | end |
854 | 818 |
|
855 | 819 | it "returns a snake-cased key" do |
|
0 commit comments