1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Added guard against [Bug #16497]

This commit is contained in:
Nobuyoshi Nakada 2020-03-15 22:15:39 +09:00
parent a8ced388fd
commit 1ad9b231ca
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -1,6 +1,26 @@
require_relative '../../spec_helper'
require 'stringio'
bug_guard = Class.new(VersionGuard) do
VERSION = StringIO.const_defined?(:VERSION) ? StringIO::VERSION : "0.0.2"
def initialize(bug, version)
@bug = bug
super(version)
@parameters = [bug, version]
end
def match?
if Range === @version
@version.include? VERSION
else
VERSION >= @version
end
end
def self.against(*args, &block)
new(*args).run_unless(:stringio_version_is, &block)
end
end
describe "StringIO#initialize when passed [Object, mode]" do
before :each do
@io = StringIO.allocate
@ -206,7 +226,9 @@ describe "StringIO#initialize sets the encoding to" do
it "the same as the encoding of the String when passed a String" do
s = ''.force_encoding(Encoding::EUC_JP)
io = StringIO.new(s)
io.external_encoding.should == Encoding::EUC_JP
bug_guard.against("[Bug #16497]", "0.0.3"..."0.1.1") do
io.external_encoding.should == Encoding::EUC_JP
end
io.string.encoding.should == Encoding::EUC_JP
end
end