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

Guarded the examples for deprecated "taint"

This commit is contained in:
Nobuyoshi Nakada 2020-01-23 22:03:13 +09:00
parent 27ac1c615d
commit 109183c2c0
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
3 changed files with 32 additions and 22 deletions

View file

@ -36,10 +36,12 @@ describe "StringIO#<< when passed [Object]" do
end end
end end
ruby_version_is ""..."2.8" do
it "does not taint self when the passed argument is tainted" do it "does not taint self when the passed argument is tainted" do
(@io << "test".taint) (@io << "test".taint)
@io.tainted?.should be_false @io.tainted?.should be_false
end end
end
it "updates self's position" do it "updates self's position" do
@io << "test" @io << "test"

View file

@ -23,6 +23,7 @@ describe "StringIO#reopen when passed [Object, Integer]" do
@io.string.should == "reopened, another time" @io.string.should == "reopened, another time"
end end
ruby_version_is ""..."2.8" do
# NOTE: WEIRD! # NOTE: WEIRD!
it "does not taint self when the passed Object was tainted" do it "does not taint self when the passed Object was tainted" do
@io.reopen("reopened".taint, IO::RDONLY) @io.reopen("reopened".taint, IO::RDONLY)
@ -31,6 +32,7 @@ describe "StringIO#reopen when passed [Object, Integer]" do
@io.reopen("reopened".taint, IO::WRONLY) @io.reopen("reopened".taint, IO::WRONLY)
@io.tainted?.should be_false @io.tainted?.should be_false
end end
end
it "tries to convert the passed Object to a String using #to_str" do it "tries to convert the passed Object to a String using #to_str" do
obj = mock("to_str") obj = mock("to_str")
@ -90,6 +92,7 @@ describe "StringIO#reopen when passed [Object, Object]" do
str.should == "" str.should == ""
end end
ruby_version_is ""..."2.8" do
# NOTE: WEIRD! # NOTE: WEIRD!
it "does not taint self when the passed Object was tainted" do it "does not taint self when the passed Object was tainted" do
@io.reopen("reopened".taint, "r") @io.reopen("reopened".taint, "r")
@ -98,6 +101,7 @@ describe "StringIO#reopen when passed [Object, Object]" do
@io.reopen("reopened".taint, "w") @io.reopen("reopened".taint, "w")
@io.tainted?.should be_false @io.tainted?.should be_false
end end
end
it "tries to convert the passed Object to a String using #to_str" do it "tries to convert the passed Object to a String using #to_str" do
obj = mock("to_str") obj = mock("to_str")
@ -160,11 +164,13 @@ describe "StringIO#reopen when passed [String]" do
@io.string.should == "reopened" @io.string.should == "reopened"
end end
ruby_version_is ""..."2.8" do
# NOTE: WEIRD! # NOTE: WEIRD!
it "does not taint self when the passed Object was tainted" do it "does not taint self when the passed Object was tainted" do
@io.reopen("reopened".taint) @io.reopen("reopened".taint)
@io.tainted?.should be_false @io.tainted?.should be_false
end end
end
it "resets self's position to 0" do it "resets self's position to 0" do
@io.read(5) @io.read(5)

View file

@ -52,10 +52,12 @@ describe :stringio_write_string, shared: true do
end end
end end
ruby_version_is ""..."2.8" do
it "does not taint self when the passed argument is tainted" do it "does not taint self when the passed argument is tainted" do
@io.send(@method, "test".taint) @io.send(@method, "test".taint)
@io.tainted?.should be_false @io.tainted?.should be_false
end end
end
end end
describe :stringio_write_not_writable, shared: true do describe :stringio_write_not_writable, shared: true do