diff options
Diffstat (limited to 'spec/ruby/library/stringio/readline_spec.rb')
-rw-r--r-- | spec/ruby/library/stringio/readline_spec.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb index 94b67bc92d..b16a16e23f 100644 --- a/spec/ruby/library/stringio/readline_spec.rb +++ b/spec/ruby/library/stringio/readline_spec.rb @@ -113,7 +113,7 @@ end describe "StringIO#readline when in write-only mode" do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.readline }.should raise_error(IOError) io = StringIO.new("xyz") @@ -128,3 +128,23 @@ describe "StringIO#readline when passed [chomp]" do io.readline(chomp: true).should == "this>is>an>example" end end + +describe "StringIO#readline when passed [limit]" do + before :each do + @io = StringIO.new("this>is>an>example") + end + + it "returns the data read until the limit is met" do + io = StringIO.new("this>is>an>example\n") + io.readline(3).should == "thi" + end + + it "returns a blank string when passed a limit of 0" do + @io.readline(0).should == "" + end + + it "ignores it when the limit is negative" do + seen = [] + @io.readline(-4).should == "this>is>an>example" + end +end |