[ruby/open-uri] Update error message for `request_specific_fields` option validation

Added `inspect` to the `request_specific_fields` value to provide
better visibility for users in the exception message.

https://github.com/ruby/open-uri/commit/f89ce5112d
This commit is contained in:
otegami 2024-09-06 09:32:15 +09:00 коммит произвёл git
Родитель 76475bf5c0
Коммит 903f3790ad
2 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -151,7 +151,7 @@ module OpenURI
end
if options.has_key? :request_specific_fields
if !(options[:request_specific_fields].is_a?(Hash) || options[:request_specific_fields].is_a?(Proc))
raise ArgumentError, "Invalid request_specific_fields' format: #{options[:request_specific_fields]}"
raise ArgumentError, "Invalid request_specific_fields option: #{options[:request_specific_fields].inspect}"
end
end
unless mode == nil ||

Просмотреть файл

@ -393,7 +393,7 @@ class TestOpenURI < Test::Unit::TestCase
with_http {|srv, url|
srv.mount_proc("/r1/", lambda {|req, res| res.body = "r1" } )
exc = assert_raise(ArgumentError) { URI.open("#{url}/r1/", request_specific_fields: "dummy_token") {} }
assert_equal("Invalid request_specific_fields' format: dummy_token", exc.message)
assert_equal('Invalid request_specific_fields option: "dummy_token"', exc.message)
}
end