summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringio/external_encoding_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringio/external_encoding_spec.rb')
-rw-r--r--spec/ruby/library/stringio/external_encoding_spec.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/spec/ruby/library/stringio/external_encoding_spec.rb b/spec/ruby/library/stringio/external_encoding_spec.rb
index 9bf2d8ee8c..6c5edb1713 100644
--- a/spec/ruby/library/stringio/external_encoding_spec.rb
+++ b/spec/ruby/library/stringio/external_encoding_spec.rb
@@ -1,5 +1,5 @@
require 'stringio'
-require File.expand_path('../../../spec_helper', __FILE__)
+require_relative '../../spec_helper'
describe "StringIO#external_encoding" do
it "gets the encoding of the underlying String" do
@@ -8,14 +8,18 @@ describe "StringIO#external_encoding" do
io.external_encoding.should == Encoding::EUC_JP
end
- ruby_version_is "2.3" do
- it "does not set the encoding of its buffer string if the string is frozen" do
- str = "foo".freeze
- enc = str.encoding
- io = StringIO.new(str)
- io.set_encoding Encoding::EUC_JP
- io.external_encoding.should == Encoding::EUC_JP
- str.encoding.should == enc
- end
+ it "changes to match string if string's encoding is changed" do
+ io = StringIO.new
+ io.string.force_encoding(Encoding::EUC_JP)
+ io.external_encoding.should == Encoding::EUC_JP
+ end
+
+ it "does not set the encoding of its buffer string if the string is frozen" do
+ str = "foo".freeze
+ enc = str.encoding
+ io = StringIO.new(str)
+ io.set_encoding Encoding::EUC_JP
+ io.external_encoding.should == Encoding::EUC_JP
+ str.encoding.should == enc
end
end