summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-06-12 12:24:38 +0200
committerJean Boussier <[email protected]>2024-06-12 20:57:31 +0200
commitc81360db757bf1c1efbd36bb160e71de94bed8ed (patch)
tree2309a0c439ef1cb5ba7e9680f9dca4554eaa922b /spec/ruby
parentce06924a17176d18816d968867858f97401d7c82 (diff)
Kernel#warn: don't call `Warning.warn` unless the category is enabled
[Bug #20573] Followup: https://github.com/ruby/ruby/pull/10960 I believe `Kernel#warn` should behave in the same way than internal `rb_warning_* APIs
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/warning/warn_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/ruby/core/warning/warn_spec.rb b/spec/ruby/core/warning/warn_spec.rb
index 8f96fe9287..1c21fe29e0 100644
--- a/spec/ruby/core/warning/warn_spec.rb
+++ b/spec/ruby/core/warning/warn_spec.rb
@@ -121,6 +121,30 @@ describe "Warning.warn" do
end
end
+ ruby_bug '#19530', ''...'3.4' do
+ it "isn't called by Kernel.warn when category is :deprecated but Warning[:deprecated] is false" do
+ warn_deprecated = Warning[:deprecated]
+ begin
+ Warning[:deprecated] = false
+ Warning.should_not_receive(:warn)
+ Kernel.warn("foo", category: :deprecated)
+ ensure
+ Warning[:deprecated] = warn_deprecated
+ end
+ end
+
+ it "isn't called by Kernel.warn when category is :experimental but Warning[:experimental] is false" do
+ warn_experimental = Warning[:experimental]
+ begin
+ Warning[:experimental] = false
+ Warning.should_not_receive(:warn)
+ Kernel.warn("foo", category: :experimental)
+ ensure
+ Warning[:experimental] = warn_experimental
+ end
+ end
+ end
+
it "prints the message when VERBOSE is false" do
-> { Warning.warn("foo") }.should complain("foo")
end