|
729 | 729 | it "raises IndexError for invalid indexes" do |
730 | 730 | expect { ten.fetch(20) }.to raise_error(IndexError) |
731 | 731 | end |
732 | | - end |
733 | 732 |
|
734 | | - describe "#fetch with a default value" do |
735 | | - it "accepts two arguments" do |
736 | | - expect { ten.fetch(0, nil) }.not_to raise_error |
737 | | - end |
| 733 | + describe "with a default value" do |
| 734 | + it "accepts two arguments" do |
| 735 | + expect { ten.fetch(0, nil) }.not_to raise_error |
| 736 | + end |
738 | 737 |
|
739 | | - it "returns the second argument for invalid indexes" do |
740 | | - expect { ten.fetch(20, nil) }.not_to raise_error |
741 | | - expect(ten.fetch(20, true)).to eq true |
| 738 | + it "returns the second argument for invalid indexes" do |
| 739 | + expect { ten.fetch(20, nil) }.not_to raise_error |
| 740 | + expect(ten.fetch(20, true)).to eq true |
| 741 | + end |
742 | 742 | end |
743 | | - end |
744 | 743 |
|
745 | | - describe "#fetch with a block" do |
746 | | - it "yields to the given block for invalid indexes" do |
747 | | - expect { ten.fetch(20) { |index| } }.not_to raise_error |
748 | | - expect(ten.fetch(20) { |index| true }).to be_truthy |
| 744 | + describe "with a block" do |
| 745 | + it "yields to the given block for invalid indexes" do |
| 746 | + expect { ten.fetch(20) { |index| } }.not_to raise_error |
| 747 | + expect(ten.fetch(20) { |index| true }).to be_truthy |
| 748 | + end |
749 | 749 | end |
750 | 750 | end |
751 | 751 |
|
|
815 | 815 | end |
816 | 816 | end |
817 | 817 |
|
818 | | - describe "#each_subject without a block" do |
819 | | - it "requires no arguments" do |
820 | | - expect { ten.each_subject }.not_to raise_error |
821 | | - end |
| 818 | + describe "#each_subject" do |
| 819 | + describe "without a block" do |
| 820 | + it "requires no arguments" do |
| 821 | + expect { ten.each_subject }.not_to raise_error |
| 822 | + end |
822 | 823 |
|
823 | | - it "returns an enumerator" do |
824 | | - expect(abc.each_subject).to be_an_enumerator |
| 824 | + it "returns an enumerator" do |
| 825 | + expect(abc.each_subject).to be_an_enumerator |
| 826 | + end |
825 | 827 | end |
826 | | - end |
827 | 828 |
|
828 | | - describe "#each_subject with a block" do |
829 | | - it "requires no arguments" do |
830 | | - expect { ten.each_subject { |subject| } }.not_to raise_error |
831 | | - end |
| 829 | + describe "with a block" do |
| 830 | + it "requires no arguments" do |
| 831 | + expect { ten.each_subject { |subject| } }.not_to raise_error |
| 832 | + end |
832 | 833 |
|
833 | | - it "yields all subject terms in the list" do |
834 | | - expect {|b| ten.each_subject(&b)}.to yield_control.exactly(10).times |
| 834 | + it "yields all subject terms in the list" do |
| 835 | + expect {|b| ten.each_subject(&b)}.to yield_control.exactly(10).times |
| 836 | + end |
835 | 837 | end |
836 | 838 | end |
837 | 839 |
|
838 | | - describe "#each without a block" do |
839 | | - it "requires no arguments" do |
840 | | - expect { ten.each }.not_to raise_error |
841 | | - end |
| 840 | + describe "#each" do |
| 841 | + describe "without a block" do |
| 842 | + it "requires no arguments" do |
| 843 | + expect { ten.each }.not_to raise_error |
| 844 | + end |
842 | 845 |
|
843 | | - it "returns an enumerator" do |
844 | | - expect(abc.each_subject).to be_an_enumerator |
| 846 | + it "returns an enumerator" do |
| 847 | + expect(abc.each_subject).to be_an_enumerator |
| 848 | + end |
845 | 849 | end |
846 | | - end |
847 | 850 |
|
848 | | - describe "#each with a block" do |
849 | | - it "requires no arguments" do |
850 | | - expect { ten.each { |value| } }.not_to raise_error |
851 | | - end |
| 851 | + describe "with a block" do |
| 852 | + it "requires no arguments" do |
| 853 | + expect { ten.each { |value| } }.not_to raise_error |
| 854 | + end |
852 | 855 |
|
853 | | - it "yields the correct number of times" do |
854 | | - expect(abc.each.count).to eq 3 |
855 | | - expect(ten.each.count).to eq 10 |
| 856 | + it "yields the correct number of times" do |
| 857 | + expect(abc.each.count).to eq 3 |
| 858 | + expect(ten.each.count).to eq 10 |
| 859 | + end |
856 | 860 | end |
857 | 861 | end |
858 | 862 |
|
859 | | - describe "#each_statement without a block" do |
860 | | - it "requires no arguments" do |
861 | | - expect { ten.each_statement }.not_to raise_error |
862 | | - end |
| 863 | + describe "#each_statement" do |
| 864 | + describe "without a block" do |
| 865 | + it "requires no arguments" do |
| 866 | + expect { ten.each_statement }.not_to raise_error |
| 867 | + end |
863 | 868 |
|
864 | | - it "returns an enumerator" do |
865 | | - expect(abc.each_subject).to be_an_enumerator |
| 869 | + it "returns an enumerator" do |
| 870 | + expect(abc.each_subject).to be_an_enumerator |
| 871 | + end |
866 | 872 | end |
867 | | - end |
868 | 873 |
|
869 | | - describe "#each_statement with a block" do |
870 | | - it "requires no arguments" do |
871 | | - expect { ten.each_statement { |statement| } }.not_to raise_error |
872 | | - end |
| 874 | + describe "with a block" do |
| 875 | + it "requires no arguments" do |
| 876 | + expect { ten.each_statement { |statement| } }.not_to raise_error |
| 877 | + end |
873 | 878 |
|
874 | | - it "yields the correct number of times" do |
875 | | - expect(abc.each_statement.count).to eq 3 * 2 |
876 | | - expect(ten.each_statement.count).to eq 10 * 2 |
877 | | - end |
| 879 | + it "yields the correct number of times" do |
| 880 | + expect(abc.each_statement.count).to eq 3 * 2 |
| 881 | + expect(ten.each_statement.count).to eq 10 * 2 |
| 882 | + end |
878 | 883 |
|
879 | | - it "yields statements" do |
880 | | - expect {|b| ten.each_statement(&b)}.to yield_control.at_least(10).times |
881 | | - ten.each_statement do |statement| |
882 | | - expect(statement).to be_a_statement |
| 884 | + it "yields statements" do |
| 885 | + expect {|b| ten.each_statement(&b)}.to yield_control.at_least(10).times |
| 886 | + ten.each_statement do |statement| |
| 887 | + expect(statement).to be_a_statement |
| 888 | + end |
883 | 889 | end |
884 | 890 | end |
885 | 891 | end |
|
930 | 936 | end |
931 | 937 | end |
932 | 938 |
|
933 | | - describe "#sort without a block" do |
934 | | - it "requires no arguments" do |
935 | | - expect { empty.sort }.not_to raise_error |
936 | | - end |
| 939 | + describe "#sort" do |
| 940 | + describe "without a block" do |
| 941 | + it "requires no arguments" do |
| 942 | + expect { empty.sort }.not_to raise_error |
| 943 | + end |
937 | 944 |
|
938 | | - it "returns a list" do |
939 | | - expect(ten.sort).to be_a_list |
| 945 | + it "returns a list" do |
| 946 | + expect(ten.sort).to be_a_list |
| 947 | + end |
940 | 948 | end |
941 | | - end |
942 | 949 |
|
943 | | - describe "#sort with a block" do |
944 | | - it "requires no arguments" do |
945 | | - expect { empty.sort { |a, b| } }.not_to raise_error |
946 | | - end |
| 950 | + describe "with a block" do |
| 951 | + it "requires no arguments" do |
| 952 | + expect { empty.sort { |a, b| } }.not_to raise_error |
| 953 | + end |
947 | 954 |
|
948 | | - it "returns a list" do |
949 | | - expect(ten.sort { |a, b| a <=> b }).to be_a_list |
| 955 | + it "returns a list" do |
| 956 | + expect(ten.sort { |a, b| a <=> b }).to be_a_list |
| 957 | + end |
950 | 958 | end |
951 | 959 | end |
952 | 960 |
|
953 | | - describe "#sort_by with a block" do |
954 | | - it "requires no arguments" do |
955 | | - expect { empty.sort_by { |value| } }.not_to raise_error |
956 | | - end |
| 961 | + describe "#sort_by" do |
| 962 | + describe "with a block" do |
| 963 | + it "requires no arguments" do |
| 964 | + expect { empty.sort_by { |value| } }.not_to raise_error |
| 965 | + end |
957 | 966 |
|
958 | | - it "returns a list" do |
959 | | - expect(ten.sort_by(&:to_i)).to be_a_list |
| 967 | + it "returns a list" do |
| 968 | + expect(ten.sort_by(&:to_i)).to be_a_list |
| 969 | + end |
960 | 970 | end |
961 | 971 | end |
962 | 972 |
|
|
0 commit comments