Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ruby 2.7...3.0 specs for Object#{taint,untaint,trust,untrust} #802

Merged
merged 2 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/kernel/taint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,20 @@
end
end
end

ruby_version_is "2.7"..."3.0" do
it "is a no-op" do
o = Object.new
o.taint
o.should_not.tainted?
end

it "warns in verbose mode" do
-> {
$VERBOSE = true
obj = mock("tainted")
obj.taint
}.should complain(/Object#taint is deprecated and will be removed in Ruby 3.2/)
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe $VERBOSE should be rolled back to default value to not affect other specs. AFAIK it isn't done by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed all spots to use complain("...", verbose: true). I think that would address this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, complain() will restore it properly.
BTW I recently added a check that $VERBOSE isn't changed by a spec example in MSpec, just not merged upstream yet.

end
18 changes: 18 additions & 0 deletions core/kernel/tainted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,22 @@
p.should.tainted?
end
end

ruby_version_is "2.7"..."3.0" do
it "is a no-op" do
o = mock('o')
p = mock('p')
p.taint
o.should_not.tainted?
p.should_not.tainted?
end

it "warns in verbose mode" do
-> {
$VERBOSE = true
o = mock('o')
o.tainted?
}.should complain(/Object#tainted\? is deprecated and will be removed in Ruby 3.2/)
end
end
end
16 changes: 16 additions & 0 deletions core/kernel/trust_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@
o.trust.should equal(o)
end
end

ruby_version_is "2.7"..."3.0" do
it "is a no-op" do
o = Object.new.untrust
o.trust
o.should_not.untrusted?
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether I understand what this case checks.

It might check that trust method doesn't change object state. But o.should_not.untrusted? assertion checks that untrusted? returns false. Wouldn't it be expected behavior if trust worked and changed an object state?

Copy link
Contributor Author

@HeroProtagonist HeroProtagonist Oct 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put an o.should_not.untrusted? above the o.trust to show nothing happens


it "warns in verbose mode" do
-> {
$VERBOSE = true
o = Object.new.untrust
o.trust
}.should complain(/Object#trust is deprecated and will be removed in Ruby 3.2/)
end
end
end
16 changes: 16 additions & 0 deletions core/kernel/untaint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@
o.untaint.should equal(o)
end
end

ruby_version_is "2.7"..."3.0" do
it "is a no-op" do
o = Object.new.taint
o.untaint
o.should_not.tainted?
end

it "warns in verbose mode" do
-> {
$VERBOSE = true
o = Object.new.taint
o.untaint
}.should complain(/Object#untaint is deprecated and will be removed in Ruby 3.2/)
end
end
end
16 changes: 16 additions & 0 deletions core/kernel/untrust_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,20 @@
o.untrust.should equal(o)
end
end

ruby_version_is "2.7"..."3.0" do
it "is a no-op" do
o = Object.new
o.untrust
o.should_not.untrusted?
end

it "warns in verbose mode" do
-> {
$VERBOSE = true
o = Object.new
o.untrust
}.should complain(/Object#untrust is deprecated and will be removed in Ruby 3.2/)
end
end
end
17 changes: 17 additions & 0 deletions core/kernel/untrusted_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,21 @@
-> { d.untrust }.should_not raise_error(RuntimeError)
end
end

ruby_version_is "2.7"..."3.0" do
it "is a no-op" do
o = mock('o')
o.should_not.untrusted?
o.untrust
o.should_not.untrusted?
end

it "warns in verbose mode" do
-> {
$VERBOSE = true
o = mock('o')
o.untrusted?
}.should complain(/Object#untrusted\? is deprecated and will be removed in Ruby 3.2/)
end
end
end