Skip to content

Disallow Warning.process(Regexp, &block) #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/warning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ 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}"
end

if block
if actions
raise ArgumentError, "cannot pass both actions and block to Warning.process"
Expand Down
7 changes: 7 additions & 0 deletions test/test_warning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,13 @@ def test_warning_process_no_action_and_no_block
end
end

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")
end

if RUBY_VERSION >= '3.0'
def test_warning_warn_category_keyword
assert_warning('foo') do
Expand Down