Skip to content
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

Fix wrong error message for unknown constant on URI #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 2 additions & 2 deletions lib/uri/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ def self.const_missing(const)
elsif value = RFC2396_PARSER.regexp[const]
warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE
value
elsif value = RFC2396_Parser.const_get(const)
elsif RFC2396_Parser.const_defined?(const)
warn "URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE
value
RFC2396_Parser.const_get(const)
else
super
end
Expand Down
3 changes: 2 additions & 1 deletion test/uri/test_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def test_fallback_constants
orig_verbose = $VERBOSE
$VERBOSE = nil

assert_raise(NameError) { URI::FOO }
e = assert_raise(NameError) { URI::FOO }
assert_equal(e.message, "uninitialized constant URI::FOO")

assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI]
assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN
Expand Down