From 6f6918a360b996184f1d18a15aaebe630069eb84 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jul 2024 12:41:49 +0900 Subject: [PATCH] Split URI::Parser examples with RFC2396 and RFC3986 Prepare for https://github.com/ruby/uri/pull/107 --- library/uri/shared/parse.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/uri/shared/parse.rb b/library/uri/shared/parse.rb index 87e1ee933e..c5057b6c4b 100644 --- a/library/uri/shared/parse.rb +++ b/library/uri/shared/parse.rb @@ -192,8 +192,15 @@ file.should be_kind_of(URI::Generic) end - it "raises errors on malformed URIs" do - -> { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError) - -> { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError) + if URI::DEFAULT_PARSER == URI::RFC2396_Parser + it "raises errors on malformed URIs" do + -> { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError) + -> { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError) + end + elsif URI::DEFAULT_PARSER == URI::RFC3986_Parser + it "does not raise errors on URIs contained underscore" do + -> { @object.parse('http://a_b:80/') }.should_not raise_error(URI::InvalidURIError) + -> { @object.parse('http://a_b/') }.should_not raise_error(URI::InvalidURIError) + end end end