diff --git a/CHANGELOG b/CHANGELOG index aac07c9..4589740 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +=== master + +* Raise ArgumentError if Warning.process is passed non-String as first argument (splattael) (#17, #19) + === 1.2.1 (2021-10-04) * Recognize additional void context warnings (kachick) (#13) diff --git a/lib/warning.rb b/lib/warning.rb index a279a5d..89eb919 100644 --- a/lib/warning.rb +++ b/lib/warning.rb @@ -145,7 +145,7 @@ def ignore(regexp, path='') # Warning.process(__FILE__, :missing_ivar=>:backtrace, :keyword_separation=>:raise) def process(path='', actions=nil, &block) unless path.is_a?(String) - raise ArgumentError, "path must be a String not a #{path.class}" + raise ArgumentError, "path must be a String (given an instance of #{path.class})" end if block diff --git a/test/test_warning.rb b/test/test_warning.rb index c6642a3..6e12547 100644 --- a/test/test_warning.rb +++ b/test/test_warning.rb @@ -547,7 +547,7 @@ def test_warning_process_path_no_string e = assert_raises(ArgumentError) do Warning.process(/foo/) { :raise } end - assert_includes(e.message, "path must be a String not a Regexp") + assert_includes(e.message, "path must be a String (given an instance of Regexp)") end if RUBY_VERSION >= '3.0'