summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/object_spec.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-24 20:59:12 -0700
committerJeremy Evans <code@jeremyevans.net>2019-11-18 01:00:25 +0200
commitffd0820ab317542f8780aac475da590a4bdbc7a8 (patch)
tree6a5d774933c15fd2b9ea948bd3ae2fa587faaf82 /spec/ruby/optional/capi/object_spec.rb
parentc5c05460ac20abcbc0ed686eb4acf06da7a39a79 (diff)
Deprecate taint/trust and related methods, and make the methods no-ops
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2476
Diffstat (limited to 'spec/ruby/optional/capi/object_spec.rb')
-rw-r--r--spec/ruby/optional/capi/object_spec.rb120
1 files changed, 65 insertions, 55 deletions
diff --git a/spec/ruby/optional/capi/object_spec.rb b/spec/ruby/optional/capi/object_spec.rb
index 43b74b9151..30abe715e7 100644
--- a/spec/ruby/optional/capi/object_spec.rb
+++ b/spec/ruby/optional/capi/object_spec.rb
@@ -414,11 +414,13 @@ describe "CApiObject" do
end
describe "FL_TEST" do
- it "returns correct status for FL_TAINT" do
- obj = Object.new
- @o.FL_TEST(obj, "FL_TAINT").should == 0
- obj.taint
- @o.FL_TEST(obj, "FL_TAINT").should_not == 0
+ ruby_version_is ''...'2.7' do
+ it "returns correct status for FL_TAINT" do
+ obj = Object.new
+ @o.FL_TEST(obj, "FL_TAINT").should == 0
+ obj.taint
+ @o.FL_TEST(obj, "FL_TAINT").should_not == 0
+ end
end
it "returns correct status for FL_FREEZE" do
@@ -570,61 +572,67 @@ describe "CApiObject" do
end
describe "OBJ_TAINT" do
- it "taints the object" do
- obj = mock("tainted")
- @o.OBJ_TAINT(obj)
- obj.tainted?.should be_true
+ ruby_version_is ''...'2.7' do
+ it "taints the object" do
+ obj = mock("tainted")
+ @o.OBJ_TAINT(obj)
+ obj.tainted?.should be_true
+ end
end
end
describe "OBJ_TAINTED" do
- it "returns C true if the object is tainted" do
- obj = mock("tainted")
- obj.taint
- @o.OBJ_TAINTED(obj).should be_true
- end
+ ruby_version_is ''...'2.7' do
+ it "returns C true if the object is tainted" do
+ obj = mock("tainted")
+ obj.taint
+ @o.OBJ_TAINTED(obj).should be_true
+ end
- it "returns C false if the object is not tainted" do
- obj = mock("untainted")
- @o.OBJ_TAINTED(obj).should be_false
+ it "returns C false if the object is not tainted" do
+ obj = mock("untainted")
+ @o.OBJ_TAINTED(obj).should be_false
+ end
end
end
describe "OBJ_INFECT" do
- it "does not taint the first argument if the second argument is not tainted" do
- host = mock("host")
- source = mock("source")
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_false
- end
+ ruby_version_is ''...'2.7' do
+ it "does not taint the first argument if the second argument is not tainted" do
+ host = mock("host")
+ source = mock("source")
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_false
+ end
- it "taints the first argument if the second argument is tainted" do
- host = mock("host")
- source = mock("source").taint
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_true
- end
+ it "taints the first argument if the second argument is tainted" do
+ host = mock("host")
+ source = mock("source").taint
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_true
+ end
- it "does not untrust the first argument if the second argument is trusted" do
- host = mock("host")
- source = mock("source")
- @o.OBJ_INFECT(host, source)
- host.untrusted?.should be_false
- end
+ it "does not untrust the first argument if the second argument is trusted" do
+ host = mock("host")
+ source = mock("source")
+ @o.OBJ_INFECT(host, source)
+ host.untrusted?.should be_false
+ end
- it "untrusts the first argument if the second argument is untrusted" do
- host = mock("host")
- source = mock("source").untrust
- @o.OBJ_INFECT(host, source)
- host.untrusted?.should be_true
- end
+ it "untrusts the first argument if the second argument is untrusted" do
+ host = mock("host")
+ source = mock("source").untrust
+ @o.OBJ_INFECT(host, source)
+ host.untrusted?.should be_true
+ end
- it "propagates both taint and distrust" do
- host = mock("host")
- source = mock("source").taint.untrust
- @o.OBJ_INFECT(host, source)
- host.tainted?.should be_true
- host.untrusted?.should be_true
+ it "propagates both taint and distrust" do
+ host = mock("host")
+ source = mock("source").taint.untrust
+ @o.OBJ_INFECT(host, source)
+ host.tainted?.should be_true
+ host.untrusted?.should be_true
+ end
end
end
@@ -659,15 +667,17 @@ describe "CApiObject" do
end
describe "rb_obj_taint" do
- it "marks the object passed as tainted" do
- obj = ""
- obj.tainted?.should == false
- @o.rb_obj_taint(obj)
- obj.tainted?.should == true
- end
+ ruby_version_is ''...'2.7' do
+ it "marks the object passed as tainted" do
+ obj = ""
+ obj.tainted?.should == false
+ @o.rb_obj_taint(obj)
+ obj.tainted?.should == true
+ end
- it "raises a #{frozen_error_class} if the object passed is frozen" do
- -> { @o.rb_obj_taint("".freeze) }.should raise_error(frozen_error_class)
+ it "raises a #{frozen_error_class} if the object passed is frozen" do
+ -> { @o.rb_obj_taint("".freeze) }.should raise_error(frozen_error_class)
+ end
end
end