1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-12-01 15:41:50 +00:00
parent 821d9a2d30
commit 4d7b0b9112
104 changed files with 2105 additions and 510 deletions

View file

@ -115,6 +115,47 @@ describe :io_each, shared: true do
end
end
describe "with both separator and limit" do
describe "when no block is given" do
it "returns an Enumerator" do
enum = @io.send(@method, nil, 1024)
enum.should be_an_instance_of(Enumerator)
enum.each { |l| ScratchPad << l }
ScratchPad.recorded.should == [IOSpecs.lines.join]
end
describe "returned Enumerator" do
describe "size" do
it "should return nil" do
@io.send(@method, nil, 1024).size.should == nil
end
end
end
end
describe "when a block is given" do
it "accepts an empty block" do
@io.send(@method, nil, 1024) {}.should equal(@io)
end
describe "when passed nil as a separator" do
it "yields self's content starting from the current position when the passed separator is nil" do
@io.pos = 100
@io.send(@method, nil, 1024) { |s| ScratchPad << s }
ScratchPad.recorded.should == ["qui a linha cinco.\nHere is line six.\n"]
end
end
describe "when passed an empty String as a separator" do
it "yields each paragraph" do
@io.send(@method, "", 1024) { |s| ScratchPad << s }
ScratchPad.recorded.should == IOSpecs.paragraphs
end
end
end
end
ruby_version_is "2.4" do
describe "when passed chomp" do
it "yields each line without trailing newline characters to the passed block" do