diff options
Diffstat (limited to 'spec/ruby/optional/capi')
-rw-r--r-- | spec/ruby/optional/capi/object_spec.rb | 120 | ||||
-rw-r--r-- | spec/ruby/optional/capi/string_spec.rb | 44 |
2 files changed, 91 insertions, 73 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 diff --git a/spec/ruby/optional/capi/string_spec.rb b/spec/ruby/optional/capi/string_spec.rb index 53d28f7940..4da31445fe 100644 --- a/spec/ruby/optional/capi/string_spec.rb +++ b/spec/ruby/optional/capi/string_spec.rb @@ -167,8 +167,10 @@ describe "C-API String function" do @s.rb_str_new("hello", 3).should == "hel" end - it "returns a non-tainted string" do - @s.rb_str_new("hello", 5).tainted?.should == false + ruby_version_is ''...'2.7' do + it "returns a non-tainted string" do + @s.rb_str_new("hello", 5).tainted?.should == false + end end it "returns an empty string if len is 0" do @@ -305,19 +307,21 @@ describe "C-API String function" do end end - describe "rb_tainted_str_new" do - it "creates a new tainted String" do - newstring = @s.rb_tainted_str_new("test", 4) - newstring.should == "test" - newstring.tainted?.should be_true + ruby_version_is ''...'2.7' do + describe "rb_tainted_str_new" do + it "creates a new tainted String" do + newstring = @s.rb_tainted_str_new("test", 4) + newstring.should == "test" + newstring.tainted?.should be_true + end end - end - describe "rb_tainted_str_new2" do - it "creates a new tainted String" do - newstring = @s.rb_tainted_str_new2("test") - newstring.should == "test" - newstring.tainted?.should be_true + describe "rb_tainted_str_new2" do + it "creates a new tainted String" do + newstring = @s.rb_tainted_str_new2("test") + newstring.should == "test" + newstring.tainted?.should be_true + end end end @@ -684,8 +688,10 @@ describe :rb_external_str_new, shared: true do @s.send(@method, "#{x80}abc").encoding.should == Encoding::BINARY end - it "returns a tainted String" do - @s.send(@method, "abc").tainted?.should be_true + ruby_version_is ''...'2.7' do + it "returns a tainted String" do + @s.send(@method, "abc").tainted?.should be_true + end end end @@ -767,9 +773,11 @@ describe "C-API String function" do s.encoding.should equal(Encoding::EUC_JP) end - it "returns a tainted String" do - s = @s.rb_external_str_new_with_enc("abc", 3, Encoding::US_ASCII) - s.tainted?.should be_true + ruby_version_is ''...'2.7' do + it "returns a tainted String" do + s = @s.rb_external_str_new_with_enc("abc", 3, Encoding::US_ASCII) + s.tainted?.should be_true + end end end |