diff options
Diffstat (limited to 'spec/ruby/core/string/insert_spec.rb')
-rw-r--r-- | spec/ruby/core/string/insert_spec.rb | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/spec/ruby/core/string/insert_spec.rb b/spec/ruby/core/string/insert_spec.rb index 752cbb2f37..483f3c9367 100644 --- a/spec/ruby/core/string/insert_spec.rb +++ b/spec/ruby/core/string/insert_spec.rb @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- - +# frozen_string_literal: false require_relative '../../spec_helper' require_relative 'fixtures/classes' @@ -41,18 +41,6 @@ describe "String#insert with index, other" do "abcd".insert(-3, other).should == "abXYZcd" end - ruby_version_is ''...'2.7' do - it "taints self if string to insert is tainted" do - str = "abcd" - str.insert(0, "T".taint).should.tainted? - - str = "abcd" - other = mock('T') - def other.to_str() "T".taint end - str.insert(0, other).should.tainted? - end - end - it "raises a TypeError if other can't be converted to string" do -> { "abcd".insert(-6, Object.new)}.should raise_error(TypeError) -> { "abcd".insert(-6, []) }.should raise_error(TypeError) @@ -81,4 +69,13 @@ describe "String#insert with index, other" do "あれ".insert 0, pat end.should raise_error(Encoding::CompatibilityError) end + + it "should not call subclassed string methods" do + cls = Class.new(String) do + def replace(arg) + raise "should not call replace" + end + end + cls.new("abcd").insert(0, 'X').should == "Xabcd" + end end |