1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2022-06-26 14:50:14 +02:00
parent f616e81637
commit d3d5ef0cca
74 changed files with 1201 additions and 324 deletions

View file

@ -98,3 +98,21 @@ describe "StringIO#readlines when passed [chomp]" do
io.readlines(chomp: true).should == ["this>is", "an>example"]
end
end
describe "StringIO#readlines when passed [limit]" do
before :each do
@io = StringIO.new("a b c d e\n1 2 3 4 5")
end
it "returns the data read until the limit is met" do
@io.readlines(4).should == ["a b ", "c d ", "e\n", "1 2 ", "3 4 ", "5"]
end
it "raises ArgumentError when limit is 0" do
-> { @io.readlines(0) }.should raise_error(ArgumentError)
end
it "ignores it when the limit is negative" do
@io.readlines(-4).should == ["a b c d e\n", "1 2 3 4 5"]
end
end