Skip to content

Commit 2a0bcb8

Browse files
committed
Add spec for StringIO#set_encoding on a frozen string
* Closes #175.
1 parent 6064faa commit 2a0bcb8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

library/stringio/external_encoding_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,15 @@
77
io.set_encoding Encoding::EUC_JP
88
io.external_encoding.should == Encoding::EUC_JP
99
end
10+
11+
ruby_version_is "2.3" do
12+
it "does not set the encoding of its buffer string if the string is frozen" do
13+
str = "foo".freeze
14+
enc = str.encoding
15+
io = StringIO.new(str)
16+
io.set_encoding Encoding::EUC_JP
17+
io.external_encoding.should == Encoding::EUC_JP
18+
str.encoding.should == enc
19+
end
20+
end
1021
end

0 commit comments

Comments
 (0)