Sha256: 87a095858560df50231f59a05e5d53cd0c5cf4dc55cc81d4da34df4cf31118df
Contents?: true
Size: 679 Bytes
Versions: 23
Compression:
Stored size: 679 Bytes
Contents
describe "Array#each_index" do before :each do ScratchPad.record [] end it "passes the index of each element to the block" do a = ['a', 'b', 'c', 'd'] a.each_index { |i| ScratchPad << i } ScratchPad.recorded.should == [0, 1, 2, 3] end it "returns self" do a = [:a, :b, :c] a.each_index { |i| }.should equal(a) end it "is not confused by removing elements from the front" do a = [1, 2, 3] a.shift ScratchPad.record [] a.each_index { |i| ScratchPad << i } ScratchPad.recorded.should == [0, 1] a.shift ScratchPad.record [] a.each_index { |i| ScratchPad << i } ScratchPad.recorded.should == [0] end end
Version data entries
23 entries across 23 versions & 1 rubygems