summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringio/shared
diff options
context:
space:
mode:
authorAndrew Konchin <[email protected]>2024-05-09 20:35:01 +0300
committerKJ Tsanaktsidis <[email protected]>2024-05-19 12:08:05 +0900
commitad636033e2fdafb417873a3cb8667351033307b1 (patch)
tree7ce5d8d7944784ce51d6ab4734e1b8227e14e959 /spec/ruby/library/stringio/shared
parentdbbaf871de70243b78e0d2f3d3575351317b5c5c (diff)
Update to ruby/spec@6b04c1d
Diffstat (limited to 'spec/ruby/library/stringio/shared')
-rw-r--r--spec/ruby/library/stringio/shared/read.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/ruby/library/stringio/shared/read.rb b/spec/ruby/library/stringio/shared/read.rb
index e3840786d9..8ef6ec2734 100644
--- a/spec/ruby/library/stringio/shared/read.rb
+++ b/spec/ruby/library/stringio/shared/read.rb
@@ -11,10 +11,28 @@ describe :stringio_read, shared: true do
end
it "reads length bytes and writes them to the buffer String" do
- @io.send(@method, 7, buffer = +"")
+ @io.send(@method, 7, buffer = +"").should.equal?(buffer)
buffer.should == "example"
end
+ ruby_version_is ""..."3.4" do
+ it "does not preserve the encoding of the given buffer" do
+ buffer = ''.encode(Encoding::ISO_8859_1)
+ @io.send(@method, 7, buffer)
+
+ buffer.encoding.should_not == Encoding::ISO_8859_1
+ end
+ end
+
+ ruby_version_is "3.4" do
+ it "preserves the encoding of the given buffer" do
+ buffer = ''.encode(Encoding::ISO_8859_1)
+ @io.send(@method, 7, buffer)
+
+ buffer.encoding.should == Encoding::ISO_8859_1
+ end
+ end
+
it "tries to convert the passed buffer Object to a String using #to_str" do
obj = mock("to_str")
obj.should_receive(:to_str).and_return(buffer = +"")