diff options
author | Benoit Daloze <[email protected]> | 2019-06-27 21:02:36 +0200 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2019-06-27 21:02:36 +0200 |
commit | d80e44deec77678fe2d72f94c17b2409b3e794d5 (patch) | |
tree | 612bf2313550e0982dda452f48492cc069e1c21a /spec/ruby/library/stringio | |
parent | c940397116c5aef76b1c0d05561c11d43ef596a7 (diff) |
Update to ruby/spec@8d74d49
Diffstat (limited to 'spec/ruby/library/stringio')
-rw-r--r-- | spec/ruby/library/stringio/read_nonblock_spec.rb | 13 | ||||
-rw-r--r-- | spec/ruby/library/stringio/shared/read.rb | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/spec/ruby/library/stringio/read_nonblock_spec.rb b/spec/ruby/library/stringio/read_nonblock_spec.rb index 7a79eef3c5..2a8f926bd0 100644 --- a/spec/ruby/library/stringio/read_nonblock_spec.rb +++ b/spec/ruby/library/stringio/read_nonblock_spec.rb @@ -26,4 +26,17 @@ describe "StringIO#read_nonblock" do stringio.read_nonblock(3, exception: false).should == 'foo' end + context "when exception option is set to false" do + context "when the end is reached" do + it "returns nil" do + stringio = StringIO.new('') + stringio << "hello" + stringio.rewind + + stringio.read_nonblock(5).should == "hello" + stringio.read_nonblock(5, exception: false).should be_nil + end + end + end + end diff --git a/spec/ruby/library/stringio/shared/read.rb b/spec/ruby/library/stringio/shared/read.rb index 604bf880e5..139c4fb02f 100644 --- a/spec/ruby/library/stringio/shared/read.rb +++ b/spec/ruby/library/stringio/shared/read.rb @@ -69,7 +69,7 @@ describe :stringio_read_length, shared: true do end it "returns a binary String" do - @io.send(@method, 4).encoding.should == Encoding::ASCII_8BIT + @io.send(@method, 4).encoding.should == Encoding::BINARY end end |