diff options
Diffstat (limited to 'spec/ruby/core/warning')
-rw-r--r-- | spec/ruby/core/warning/element_reference_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/warning/element_set_spec.rb | 6 | ||||
-rw-r--r-- | spec/ruby/core/warning/warn_spec.rb | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/spec/ruby/core/warning/element_reference_spec.rb b/spec/ruby/core/warning/element_reference_spec.rb index a346cf535b..f51cc87de5 100644 --- a/spec/ruby/core/warning/element_reference_spec.rb +++ b/spec/ruby/core/warning/element_reference_spec.rb @@ -12,5 +12,11 @@ ruby_version_is '2.7' do it "raises for unknown category" do -> { Warning[:noop] }.should raise_error(ArgumentError, /unknown category: noop/) end + + it "raises for non-Symbol category" do + -> { Warning[42] }.should raise_error(TypeError) + -> { Warning[false] }.should raise_error(TypeError) + -> { Warning["noop"] }.should raise_error(TypeError) + end end end diff --git a/spec/ruby/core/warning/element_set_spec.rb b/spec/ruby/core/warning/element_set_spec.rb index 3b0ea45c9b..611060fb3a 100644 --- a/spec/ruby/core/warning/element_set_spec.rb +++ b/spec/ruby/core/warning/element_set_spec.rb @@ -27,5 +27,11 @@ ruby_version_is '2.7' do it "raises for unknown category" do -> { Warning[:noop] = false }.should raise_error(ArgumentError, /unknown category: noop/) end + + it "raises for non-Symbol category" do + -> { Warning[42] = false }.should raise_error(TypeError) + -> { Warning[false] = false }.should raise_error(TypeError) + -> { Warning["noop"] = false }.should raise_error(TypeError) + end end end diff --git a/spec/ruby/core/warning/warn_spec.rb b/spec/ruby/core/warning/warn_spec.rb index 2ded6a109d..5ccff3aa2b 100644 --- a/spec/ruby/core/warning/warn_spec.rb +++ b/spec/ruby/core/warning/warn_spec.rb @@ -51,7 +51,6 @@ describe "Warning.warn" do end end - ruby_version_is '3.0' do it "is called by Kernel.warn with nil category keyword" do Warning.should_receive(:warn).with("Chunky bacon!\n", category: nil) @@ -69,7 +68,7 @@ describe "Warning.warn" do verbose = $VERBOSE $VERBOSE = false begin - Kernel.warn("Chunky bacon!", category: 'deprecated') + Kernel.warn("Chunky bacon!", category: "deprecated") ensure $VERBOSE = verbose end |