summaryrefslogtreecommitdiff
path: root/spec/ruby/core/warning
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2023-04-25 17:04:25 +0200
committerBenoit Daloze <eregontp@gmail.com>2023-04-25 17:09:53 +0200
commitd562663e4098801c1d7fa7c64a335ea71231a598 (patch)
tree5b2ab2c9fbb86b4223263485fc5a3224562ae78d /spec/ruby/core/warning
parentd3da01cd110ca99dd0249ee9af92e12cf845998c (diff)
Update to ruby/spec@7f69c86
Diffstat (limited to 'spec/ruby/core/warning')
-rw-r--r--spec/ruby/core/warning/warn_spec.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/spec/ruby/core/warning/warn_spec.rb b/spec/ruby/core/warning/warn_spec.rb
index 5ccff3aa2b..e2fcfbf93f 100644
--- a/spec/ruby/core/warning/warn_spec.rb
+++ b/spec/ruby/core/warning/warn_spec.rb
@@ -73,6 +73,66 @@ describe "Warning.warn" do
$VERBOSE = verbose
end
end
+
+ it "warns when category is :deprecated and Warning[:deprecated] is true" do
+ warn_deprecated = Warning[:deprecated]
+ Warning[:deprecated] = true
+ begin
+ -> {
+ Warning.warn("foo", category: :deprecated)
+ }.should complain("foo")
+ ensure
+ Warning[:deprecated] = warn_deprecated
+ end
+ end
+
+ it "warns when category is :experimental and Warning[:experimental] is true" do
+ warn_experimental = Warning[:experimental]
+ Warning[:experimental] = true
+ begin
+ -> {
+ Warning.warn("foo", category: :experimental)
+ }.should complain("foo")
+ ensure
+ Warning[:experimental] = warn_experimental
+ end
+ end
+
+ it "doesn't print message when category is :deprecated but Warning[:deprecated] is false" do
+ warn_deprecated = Warning[:deprecated]
+ Warning[:deprecated] = false
+ begin
+ -> {
+ Warning.warn("foo", category: :deprecated)
+ }.should_not complain
+ ensure
+ Warning[:deprecated] = warn_deprecated
+ end
+ end
+
+ it "doesn't print message when category is :experimental but Warning[:experimental] is false" do
+ warn_experimental = Warning[:experimental]
+ Warning[:experimental] = false
+ begin
+ -> {
+ Warning.warn("foo", category: :experimental)
+ }.should_not complain
+ ensure
+ Warning[:experimental] = warn_experimental
+ end
+ end
+
+ it "prints the message when VERBOSE is false" do
+ -> { Warning.warn("foo") }.should complain("foo")
+ end
+
+ it "prints the message when VERBOSE is nil" do
+ -> { Warning.warn("foo") }.should complain("foo", verbose: nil)
+ end
+
+ it "prints the message when VERBOSE is true" do
+ -> { Warning.warn("foo") }.should complain("foo", verbose: true)
+ end
end
ruby_version_is ''...'3.0' do