Skip to content

Commit f28305f

Browse files
committed
Update list specs.
1 parent 8169abd commit f28305f

1 file changed

Lines changed: 88 additions & 78 deletions

File tree

spec/model_list_spec.rb

Lines changed: 88 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -729,23 +729,23 @@
729729
it "raises IndexError for invalid indexes" do
730730
expect { ten.fetch(20) }.to raise_error(IndexError)
731731
end
732-
end
733732

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
738737

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
742742
end
743-
end
744743

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
749749
end
750750
end
751751

@@ -815,71 +815,77 @@
815815
end
816816
end
817817

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
822823

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
825827
end
826-
end
827828

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
832833

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
835837
end
836838
end
837839

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
842845

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
845849
end
846-
end
847850

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
852855

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
856860
end
857861
end
858862

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
863868

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
866872
end
867-
end
868873

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
873878

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
878883

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
883889
end
884890
end
885891
end
@@ -930,33 +936,37 @@
930936
end
931937
end
932938

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
937944

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
940948
end
941-
end
942949

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
947954

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
950958
end
951959
end
952960

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
957966

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
960970
end
961971
end
962972

0 commit comments

Comments
 (0)