summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-31 14:58:31 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-09-25 09:50:33 +0900
commit996af2ce086249e904b2ce95ab2fcd1de7d757be (patch)
tree1b70f747a0eefc32be13f05bdb037275d1e664a1 /spec
parent83ff0f74bf69650754cac020bcd4ff9adbba877e (diff)
Disable deprecation warning by the default [Feature #16345]
And `-w` option turns it on.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3481
Diffstat (limited to 'spec')
-rw-r--r--spec/ruby/core/data/constants_spec.rb16
-rw-r--r--spec/ruby/core/env/index_spec.rb14
-rw-r--r--spec/ruby/core/integer/constants_spec.rb32
-rw-r--r--spec/ruby/core/kernel/match_spec.rb2
-rw-r--r--spec/ruby/core/module/deprecate_constant_spec.rb10
-rw-r--r--spec/ruby/language/predefined_spec.rb4
-rw-r--r--spec/ruby/library/net/http/HTTPServerException_spec.rb2
7 files changed, 48 insertions, 32 deletions
diff --git a/spec/ruby/core/data/constants_spec.rb b/spec/ruby/core/data/constants_spec.rb
index 0e47a82e26..18f6d4291c 100644
--- a/spec/ruby/core/data/constants_spec.rb
+++ b/spec/ruby/core/data/constants_spec.rb
@@ -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
diff --git a/spec/ruby/core/env/index_spec.rb b/spec/ruby/core/env/index_spec.rb
index 43875f5a50..a0c90f8eb2 100644
--- a/spec/ruby/core/env/index_spec.rb
+++ b/spec/ruby/core/env/index_spec.rb
@@ -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
diff --git a/spec/ruby/core/integer/constants_spec.rb b/spec/ruby/core/integer/constants_spec.rb
index 3b8b01e330..35601f82b9 100644
--- a/spec/ruby/core/integer/constants_spec.rb
+++ b/spec/ruby/core/integer/constants_spec.rb
@@ -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
diff --git a/spec/ruby/core/kernel/match_spec.rb b/spec/ruby/core/kernel/match_spec.rb
index 6dc1eb7de8..e8ef320d6f 100644
--- a/spec/ruby/core/kernel/match_spec.rb
+++ b/spec/ruby/core/kernel/match_spec.rb
@@ -14,7 +14,7 @@ describe "Kernel#=~" do
end
end
- ruby_version_is "2.6" do
+ ruby_version_is "2.6"..."3.0" do
it "is deprecated" do
-> do
Object.new =~ /regexp/
diff --git a/spec/ruby/core/module/deprecate_constant_spec.rb b/spec/ruby/core/module/deprecate_constant_spec.rb
index 7bcced981b..6a8086bc8f 100644
--- a/spec/ruby/core/module/deprecate_constant_spec.rb
+++ b/spec/ruby/core/module/deprecate_constant_spec.rb
@@ -10,6 +10,16 @@ describe "Module#deprecate_constant" do
@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
diff --git a/spec/ruby/language/predefined_spec.rb b/spec/ruby/language/predefined_spec.rb
index 5ce4e77906..cb0462731b 100644
--- a/spec/ruby/language/predefined_spec.rb
+++ b/spec/ruby/language/predefined_spec.rb
@@ -654,7 +654,7 @@ describe "Predefined global $," do
-> { $, = 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
@@ -693,7 +693,7 @@ describe "Predefined global $;" do
$; = 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
diff --git a/spec/ruby/library/net/http/HTTPServerException_spec.rb b/spec/ruby/library/net/http/HTTPServerException_spec.rb
index 87841ab499..6800c625f7 100644
--- a/spec/ruby/library/net/http/HTTPServerException_spec.rb
+++ b/spec/ruby/library/net/http/HTTPServerException_spec.rb
@@ -13,7 +13,7 @@ ruby_version_is ""..."2.6" do
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/)