Skip to content

Commit

Permalink
Disable deprecation warning by the default [Feature #16345]
Browse files Browse the repository at this point in the history
And `-w` option turns it on.
  • Loading branch information
nobu authored and eregon committed Sep 30, 2020
1 parent d31cb6c commit 56613b1
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 32 deletions.
16 changes: 9 additions & 7 deletions core/data/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
require_relative '../../spec_helper'

describe "Data" do
it "is a subclass of Object" do
suppress_warning do
Data.superclass.should == Object
ruby_version_is ""..."3.0" do
describe "Data" do
it "is a subclass of Object" do
suppress_warning do
Data.superclass.should == Object
end
end
end

it "is deprecated" do
-> { Data }.should complain(/constant ::Data is deprecated/)
it "is deprecated" do
-> { Data }.should complain(/constant ::Data is deprecated/)
end
end
end
14 changes: 8 additions & 6 deletions core/env/index_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
require_relative '../../spec_helper'
require_relative 'shared/key'

describe "ENV.index" do
it_behaves_like :env_key, :index
ruby_version_is ""..."3.0" do
describe "ENV.index" do
it_behaves_like :env_key, :index

it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
end
end
end
32 changes: 17 additions & 15 deletions core/integer/constants_spec.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
require_relative '../../spec_helper'

describe "Fixnum" do
it "is unified into Integer" do
suppress_warning do
Fixnum.should equal(Integer)
ruby_version_is ""..."3.0" do
describe "Fixnum" do
it "is unified into Integer" do
suppress_warning do
Fixnum.should equal(Integer)
end
end
end

it "is deprecated" do
-> { Fixnum }.should complain(/constant ::Fixnum is deprecated/)
it "is deprecated" do
-> { Fixnum }.should complain(/constant ::Fixnum is deprecated/)
end
end
end

describe "Bignum" do
it "is unified into Integer" do
suppress_warning do
Bignum.should equal(Integer)
describe "Bignum" do
it "is unified into Integer" do
suppress_warning do
Bignum.should equal(Integer)
end
end
end

it "is deprecated" do
-> { Bignum }.should complain(/constant ::Bignum is deprecated/)
it "is deprecated" do
-> { Bignum }.should complain(/constant ::Bignum is deprecated/)
end
end
end
2 changes: 1 addition & 1 deletion core/kernel/match_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
end
end

ruby_version_is "2.6" do
ruby_version_is "2.6"..."3.0" do
it "is deprecated" do
-> do
Object.new =~ /regexp/
Expand Down
10 changes: 10 additions & 0 deletions core/module/deprecate_constant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
@module.private_constant :PRIVATE
@module.deprecate_constant :PRIVATE
@pattern = /deprecated/
if Warning.respond_to?(:[])
@deprecated = Warning[:deprecated]
Warning[:deprecated] = true
end
end

after :each do
if Warning.respond_to?(:[])
Warning[:deprecated] = @deprecated
end
end

describe "when accessing the deprecated module" do
Expand Down
4 changes: 2 additions & 2 deletions language/predefined_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def foo
-> { $, = Object.new }.should raise_error(TypeError)
end

ruby_version_is "2.7" do
ruby_version_is "2.7"..."3.0" do
it "warns if assigned non-nil" do
-> { $, = "_" }.should complain(/warning: `\$,' is deprecated/)
end
Expand Down Expand Up @@ -693,7 +693,7 @@ def foo
$; = nil
end

ruby_version_is "2.7" do
ruby_version_is "2.7"..."3.0" do
it "warns if assigned non-nil" do
-> { $; = "_" }.should complain(/warning: `\$;' is deprecated/)
end
Expand Down
2 changes: 1 addition & 1 deletion library/net/http/HTTPServerException_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end
end

ruby_version_is "2.6" do
ruby_version_is "2.6"..."3.0" do
describe "Net::HTTPServerException" do
it "is a subclass of Net::ProtoServerError and is warned as deprecated" do
-> { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
Expand Down

0 comments on commit 56613b1

Please sign in to comment.