summaryrefslogtreecommitdiff
path: root/spec/ruby/library/uri
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/uri')
-rw-r--r--spec/ruby/library/uri/decode_www_form_component_spec.rb6
-rw-r--r--spec/ruby/library/uri/decode_www_form_spec.rb6
-rw-r--r--spec/ruby/library/uri/encode_www_form_component_spec.rb6
-rw-r--r--spec/ruby/library/uri/encode_www_form_spec.rb6
-rw-r--r--spec/ruby/library/uri/eql_spec.rb10
-rw-r--r--spec/ruby/library/uri/equality_spec.rb46
-rw-r--r--spec/ruby/library/uri/escape/decode_spec.rb6
-rw-r--r--spec/ruby/library/uri/escape/encode_spec.rb6
-rw-r--r--spec/ruby/library/uri/escape/escape_spec.rb6
-rw-r--r--spec/ruby/library/uri/escape/unescape_spec.rb6
-rw-r--r--spec/ruby/library/uri/extract_spec.rb86
-rw-r--r--spec/ruby/library/uri/fixtures/classes.rb11
-rw-r--r--spec/ruby/library/uri/fixtures/normalization.rb54
-rw-r--r--spec/ruby/library/uri/ftp/build_spec.rb6
-rw-r--r--spec/ruby/library/uri/ftp/merge_spec.rb6
-rw-r--r--spec/ruby/library/uri/ftp/new2_spec.rb6
-rw-r--r--spec/ruby/library/uri/ftp/path_spec.rb26
-rw-r--r--spec/ruby/library/uri/ftp/set_typecode_spec.rb6
-rw-r--r--spec/ruby/library/uri/ftp/to_s_spec.rb15
-rw-r--r--spec/ruby/library/uri/ftp/typecode_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/absolute_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/build2_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/build_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/coerce_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/component_ary_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/component_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/default_port_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/eql_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/equal_value_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/fragment_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/hash_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/hierarchical_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/host_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/inspect_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/merge_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/minus_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/normalize_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/opaque_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/password_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/path_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/plus_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/port_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/query_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/registry_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/relative_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/route_from_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/route_to_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/scheme_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/select_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_fragment_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_host_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_opaque_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_password_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_path_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_port_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_query_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_registry_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_scheme_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_user_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/set_userinfo_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/to_s_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/use_registry_spec.rb6
-rw-r--r--spec/ruby/library/uri/generic/user_spec.rb10
-rw-r--r--spec/ruby/library/uri/generic/userinfo_spec.rb10
-rw-r--r--spec/ruby/library/uri/http/build_spec.rb6
-rw-r--r--spec/ruby/library/uri/http/request_uri_spec.rb16
-rw-r--r--spec/ruby/library/uri/join_spec.rb57
-rw-r--r--spec/ruby/library/uri/ldap/attributes_spec.rb10
-rw-r--r--spec/ruby/library/uri/ldap/build_spec.rb6
-rw-r--r--spec/ruby/library/uri/ldap/dn_spec.rb10
-rw-r--r--spec/ruby/library/uri/ldap/extensions_spec.rb10
-rw-r--r--spec/ruby/library/uri/ldap/filter_spec.rb10
-rw-r--r--spec/ruby/library/uri/ldap/hierarchical_spec.rb6
-rw-r--r--spec/ruby/library/uri/ldap/scope_spec.rb10
-rw-r--r--spec/ruby/library/uri/ldap/set_attributes_spec.rb6
-rw-r--r--spec/ruby/library/uri/ldap/set_dn_spec.rb6
-rw-r--r--spec/ruby/library/uri/ldap/set_extensions_spec.rb6
-rw-r--r--spec/ruby/library/uri/ldap/set_filter_spec.rb6
-rw-r--r--spec/ruby/library/uri/ldap/set_scope_spec.rb6
-rw-r--r--spec/ruby/library/uri/mailto/build_spec.rb98
-rw-r--r--spec/ruby/library/uri/mailto/headers_spec.rb10
-rw-r--r--spec/ruby/library/uri/mailto/set_headers_spec.rb6
-rw-r--r--spec/ruby/library/uri/mailto/set_to_spec.rb6
-rw-r--r--spec/ruby/library/uri/mailto/to_mailtext_spec.rb6
-rw-r--r--spec/ruby/library/uri/mailto/to_rfc822text_spec.rb6
-rw-r--r--spec/ruby/library/uri/mailto/to_s_spec.rb6
-rw-r--r--spec/ruby/library/uri/mailto/to_spec.rb10
-rw-r--r--spec/ruby/library/uri/merge_spec.rb20
-rw-r--r--spec/ruby/library/uri/normalize_spec.rb35
-rw-r--r--spec/ruby/library/uri/parse_spec.rb203
-rw-r--r--spec/ruby/library/uri/parser/escape_spec.rb6
-rw-r--r--spec/ruby/library/uri/parser/extract_spec.rb7
-rw-r--r--spec/ruby/library/uri/parser/inspect_spec.rb6
-rw-r--r--spec/ruby/library/uri/parser/join_spec.rb7
-rw-r--r--spec/ruby/library/uri/parser/make_regexp_spec.rb6
-rw-r--r--spec/ruby/library/uri/parser/parse_spec.rb7
-rw-r--r--spec/ruby/library/uri/parser/split_spec.rb6
-rw-r--r--spec/ruby/library/uri/parser/unescape_spec.rb6
-rw-r--r--spec/ruby/library/uri/plus_spec.rb459
-rw-r--r--spec/ruby/library/uri/regexp_spec.rb18
-rw-r--r--spec/ruby/library/uri/route_from_spec.rb23
-rw-r--r--spec/ruby/library/uri/route_to_spec.rb26
-rw-r--r--spec/ruby/library/uri/select_spec.rb31
-rw-r--r--spec/ruby/library/uri/set_component_spec.rb47
-rw-r--r--spec/ruby/library/uri/shared/eql.rb17
-rw-r--r--spec/ruby/library/uri/shared/extract.rb83
-rw-r--r--spec/ruby/library/uri/shared/join.rb54
-rw-r--r--spec/ruby/library/uri/shared/parse.rb199
-rw-r--r--spec/ruby/library/uri/split_spec.rb6
-rw-r--r--spec/ruby/library/uri/uri_spec.rb29
-rw-r--r--spec/ruby/library/uri/util/make_components_hash_spec.rb6
111 files changed, 2284 insertions, 0 deletions
diff --git a/spec/ruby/library/uri/decode_www_form_component_spec.rb b/spec/ruby/library/uri/decode_www_form_component_spec.rb
new file mode 100644
index 0000000000..04cc634947
--- /dev/null
+++ b/spec/ruby/library/uri/decode_www_form_component_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.decode_www_form_component" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/decode_www_form_spec.rb b/spec/ruby/library/uri/decode_www_form_spec.rb
new file mode 100644
index 0000000000..d4854a6ece
--- /dev/null
+++ b/spec/ruby/library/uri/decode_www_form_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.decode_www_form" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/encode_www_form_component_spec.rb b/spec/ruby/library/uri/encode_www_form_component_spec.rb
new file mode 100644
index 0000000000..753b6d50d0
--- /dev/null
+++ b/spec/ruby/library/uri/encode_www_form_component_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.encode_www_form_component" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/encode_www_form_spec.rb b/spec/ruby/library/uri/encode_www_form_spec.rb
new file mode 100644
index 0000000000..b72b928344
--- /dev/null
+++ b/spec/ruby/library/uri/encode_www_form_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.encode_www_form" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/eql_spec.rb b/spec/ruby/library/uri/eql_spec.rb
new file mode 100644
index 0000000000..2bbc5291e9
--- /dev/null
+++ b/spec/ruby/library/uri/eql_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/normalization', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
+require 'uri'
+
+describe "URI#eql?" do
+ it_behaves_like :uri_eql, :eql?
+
+ it_behaves_like :uri_eql_against_other_types, :eql?
+end
diff --git a/spec/ruby/library/uri/equality_spec.rb b/spec/ruby/library/uri/equality_spec.rb
new file mode 100644
index 0000000000..07d48a9583
--- /dev/null
+++ b/spec/ruby/library/uri/equality_spec.rb
@@ -0,0 +1,46 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/normalization', __FILE__)
+require File.expand_path('../shared/eql', __FILE__)
+require 'uri'
+
+describe "URI#==" do
+ it "ignores capitalization of host names" do
+ URI("http://exAMPLE.cOm").should == URI("http://example.com")
+ end
+
+ it "ignores capitalization of scheme" do
+ URI("hTTp://example.com").should == URI("http://example.com")
+ end
+
+ it "treats a blank path and a path of '/' as the same" do
+ URI("http://example.com").should == URI("http://example.com/")
+ end
+
+ it "is case sensitive in all components of the URI but the host and scheme" do
+ URI("http://example.com/paTH").should_not == URI("http://example.com/path")
+ URI("http://uSer@example.com").should_not == URI("http://user@example.com")
+ URI("http://example.com/path?quERy").should_not == URI("http://example.com/path?query")
+ URI("http://example.com/#fragMENT").should_not == URI("http://example.com/#fragment")
+ end
+
+ it "differentiates based on port number" do
+ URI("http://example.com:8080").should_not == URI("http://example.com")
+ end
+
+ # Note: The previous tests will be included in following ones
+
+ it_behaves_like :uri_eql, :==
+
+ it_behaves_like :uri_eql_against_other_types, :==
+
+ quarantine! do # Quarantined until redmine:2542 is accepted
+ it "returns true only if the normalized forms are equivalent" do
+ URISpec::NORMALIZED_FORMS.each do |form|
+ normal_uri = URI(form[:normalized])
+ form[:equivalent].each do |same|
+ URI(same).should == normal_uri
+ end
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/uri/escape/decode_spec.rb b/spec/ruby/library/uri/escape/decode_spec.rb
new file mode 100644
index 0000000000..34d3e787c4
--- /dev/null
+++ b/spec/ruby/library/uri/escape/decode_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Escape#decode" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/escape/encode_spec.rb b/spec/ruby/library/uri/escape/encode_spec.rb
new file mode 100644
index 0000000000..edde60b3cd
--- /dev/null
+++ b/spec/ruby/library/uri/escape/encode_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Escape#encode" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/escape/escape_spec.rb b/spec/ruby/library/uri/escape/escape_spec.rb
new file mode 100644
index 0000000000..3c6b957b18
--- /dev/null
+++ b/spec/ruby/library/uri/escape/escape_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Escape#escape" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/escape/unescape_spec.rb b/spec/ruby/library/uri/escape/unescape_spec.rb
new file mode 100644
index 0000000000..6a7165a0d3
--- /dev/null
+++ b/spec/ruby/library/uri/escape/unescape_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Escape#unescape" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/extract_spec.rb b/spec/ruby/library/uri/extract_spec.rb
new file mode 100644
index 0000000000..7b660851b6
--- /dev/null
+++ b/spec/ruby/library/uri/extract_spec.rb
@@ -0,0 +1,86 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.extract" do
+ it "behaves according to its documentation" do
+ URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.").should == ["http://foo.example.org/bla", "mailto:test@example.com"]
+ end
+
+ it "treats contiguous URIs as a single URI" do
+ URI.extract('http://example.jphttp://example.jp').should == ['http://example.jphttp://example.jp']
+ end
+
+ it "treats pretty much anything with a colon as a URI" do
+ URI.extract('From: XXX [mailto:xxx@xxx.xxx.xxx]').should == ['From:', 'mailto:xxx@xxx.xxx.xxx]']
+ end
+
+ it "wraps a URI string in an array" do
+ URI.extract("http://github.com/brixen/rubyspec/tree/master").should == ["http://github.com/brixen/rubyspec/tree/master"]
+ end
+
+ it "pulls a variety of protocol URIs from a string" do
+ URI.extract("this is a string, it has http://rubini.us/ in it").should == ["http://rubini.us/"]
+ URI.extract("mailto:spambait@example.com").should == ["mailto:spambait@example.com"]
+ URI.extract("ftp://ruby-lang.org/").should == ["ftp://ruby-lang.org/"]
+ URI.extract("https://mail.google.com").should == ["https://mail.google.com"]
+ URI.extract("anything://example.com/").should == ["anything://example.com/"]
+ end
+
+ it "pulls all URIs within a string in order into an array when a block is not given" do
+ URI.extract("1.3. Example URI
+
+ The following examples illustrate URI that are in common use.
+
+ ftp://ftp.is.co.za/rfc/rfc1808.txt
+ -- ftp scheme for File Transfer Protocol services
+
+ gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
+ -- gopher scheme for Gopher and Gopher+ Protocol services
+
+ http://www.math.uio.no/faq/compression-faq/part1.html
+ -- http scheme for Hypertext Transfer Protocol services
+
+ mailto:mduerst@ifi.unizh.ch
+ -- mailto scheme for electronic mail addresses
+
+ news:comp.infosystems.www.servers.unix
+ -- news scheme for USENET news groups and articles
+
+ telnet://melvyl.ucop.edu/
+ -- telnet scheme for interactive services via the TELNET Protocol
+ ").should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch","news:comp.infosystems.www.servers.unix","telnet://melvyl.ucop.edu/"]
+ end
+
+ it "yields each URI in the given string in order to a block, if given, and returns nil" do
+ results = ["http://foo.example.org/bla", "mailto:test@example.com"]
+ URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") {|uri|
+ uri.should == results.shift
+ }.should == nil
+ results.should == []
+ end
+
+ it "allows the user to specify a list of acceptable protocols of URIs to scan for" do
+ URI.extract("1.3. Example URI
+
+ The following examples illustrate URI that are in common use.
+
+ ftp://ftp.is.co.za/rfc/rfc1808.txt
+ -- ftp scheme for File Transfer Protocol services
+
+ gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
+ -- gopher scheme for Gopher and Gopher+ Protocol services
+
+ http://www.math.uio.no/faq/compression-faq/part1.html
+ -- http scheme for Hypertext Transfer Protocol services
+
+ mailto:mduerst@ifi.unizh.ch
+ -- mailto scheme for electronic mail addresses
+
+ news:comp.infosystems.www.servers.unix
+ -- news scheme for USENET news groups and articles
+
+ telnet://melvyl.ucop.edu/
+ -- telnet scheme for interactive services via the TELNET Protocol
+ ", ["http","ftp","mailto"]).should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch"]
+ end
+end
diff --git a/spec/ruby/library/uri/fixtures/classes.rb b/spec/ruby/library/uri/fixtures/classes.rb
new file mode 100644
index 0000000000..e1179307cc
--- /dev/null
+++ b/spec/ruby/library/uri/fixtures/classes.rb
@@ -0,0 +1,11 @@
+require 'uri'
+
+module URISpec
+ def self.components(uri)
+ result = {}
+ uri.component.each do |component|
+ result[component] = uri.send(component)
+ end
+ result
+ end
+end
diff --git a/spec/ruby/library/uri/fixtures/normalization.rb b/spec/ruby/library/uri/fixtures/normalization.rb
new file mode 100644
index 0000000000..cbc26c9b48
--- /dev/null
+++ b/spec/ruby/library/uri/fixtures/normalization.rb
@@ -0,0 +1,54 @@
+module URISpec
+ # Not an exhaustive list. Refer to rfc3986
+ NORMALIZED_FORMS = [
+ { normalized: "http://example.com/",
+ equivalent: %w{ hTTp://example.com/
+ http://exaMple.com/
+ http://exa%4dple.com/
+ http://exa%4Dple.com/
+ http://exa%6dple.com/
+ http://exa%6Dple.com/
+ http://@example.com/
+ http://example.com:/
+ http://example.com:80/
+ http://example.com
+ },
+ different: %w{ http://example.com/#
+ http://example.com/?
+ http://example.com:8888/
+ http:///example.com
+ http:example.com
+ https://example.com/
+ },
+ },
+ { normalized: "http://example.com/index.html",
+ equivalent: %w{ http://example.com/index.ht%6dl
+ http://example.com/index.ht%6Dl
+ },
+ different: %w{ http://example.com/index.hTMl
+ http://example.com/index.ht%4dl
+ http://example.com/index
+ http://example.com/
+ http://example.com/
+ },
+ },
+ { normalized: "http://example.com/x?y#z",
+ equivalent: %w{ http://example.com/x?y#%7a
+ http://example.com/x?y#%7A
+ http://example.com/x?%79#z
+ },
+ different: %w{ http://example.com/x?Y#z
+ http://example.com/x?y#Z
+ http://example.com/x?y=#z
+ http://example.com/x?y
+ http://example.com/x#z
+ },
+ },
+ { normalized: "http://example.com/x?q=a%20b",
+ equivalent: %w{
+ },
+ different: %w{ http://example.com/x?q=a+b
+ },
+ },
+ ]
+end
diff --git a/spec/ruby/library/uri/ftp/build_spec.rb b/spec/ruby/library/uri/ftp/build_spec.rb
new file mode 100644
index 0000000000..c7765e2868
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/build_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::FTP.build" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ftp/merge_spec.rb b/spec/ruby/library/uri/ftp/merge_spec.rb
new file mode 100644
index 0000000000..b766e992ca
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/merge_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::FTP#merge" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ftp/new2_spec.rb b/spec/ruby/library/uri/ftp/new2_spec.rb
new file mode 100644
index 0000000000..a43916af6a
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/new2_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::FTP.new2" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ftp/path_spec.rb b/spec/ruby/library/uri/ftp/path_spec.rb
new file mode 100644
index 0000000000..9e1a00602f
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/path_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::FTP#path=" do
+ before :each do
+ @url = URI.parse('ftp://example.com')
+ end
+
+ it "does not require a leading /" do
+ @url.path = 'foo'
+ @url.path.should == 'foo'
+ end
+
+ it "does not strip the leading /" do
+ @url.path = '/foo'
+ @url.path.should == '/foo'
+ end
+end
+
+describe "URI::FTP#path" do
+ it "unescapes the leading /" do
+ url = URI.parse('ftp://example.com/%2Ffoo')
+
+ url.path.should == '/foo'
+ end
+end
diff --git a/spec/ruby/library/uri/ftp/set_typecode_spec.rb b/spec/ruby/library/uri/ftp/set_typecode_spec.rb
new file mode 100644
index 0000000000..b815bc8740
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/set_typecode_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::FTP#set_typecode" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ftp/to_s_spec.rb b/spec/ruby/library/uri/ftp/to_s_spec.rb
new file mode 100644
index 0000000000..e4e2832e86
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/to_s_spec.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+
+describe "URI::FTP#to_s" do
+ before :each do
+ @url = URI.parse('ftp://example.com')
+ end
+
+ it "escapes the leading /" do
+ @url.path = '/foo'
+
+ @url.to_s.should == 'ftp://example.com/%2Ffoo'
+ end
+end
diff --git a/spec/ruby/library/uri/ftp/typecode_spec.rb b/spec/ruby/library/uri/ftp/typecode_spec.rb
new file mode 100644
index 0000000000..b298c2ae98
--- /dev/null
+++ b/spec/ruby/library/uri/ftp/typecode_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::FTP#typecode" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::FTP#typecode=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/absolute_spec.rb b/spec/ruby/library/uri/generic/absolute_spec.rb
new file mode 100644
index 0000000000..4f6526b827
--- /dev/null
+++ b/spec/ruby/library/uri/generic/absolute_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#absolute" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#absolute?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/build2_spec.rb b/spec/ruby/library/uri/generic/build2_spec.rb
new file mode 100644
index 0000000000..0b9a6788f6
--- /dev/null
+++ b/spec/ruby/library/uri/generic/build2_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic.build2" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/build_spec.rb b/spec/ruby/library/uri/generic/build_spec.rb
new file mode 100644
index 0000000000..6fa5d6ac55
--- /dev/null
+++ b/spec/ruby/library/uri/generic/build_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic.build" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/coerce_spec.rb b/spec/ruby/library/uri/generic/coerce_spec.rb
new file mode 100644
index 0000000000..1b1a040f63
--- /dev/null
+++ b/spec/ruby/library/uri/generic/coerce_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#coerce" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/component_ary_spec.rb b/spec/ruby/library/uri/generic/component_ary_spec.rb
new file mode 100644
index 0000000000..3244073e0e
--- /dev/null
+++ b/spec/ruby/library/uri/generic/component_ary_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#component_ary" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/component_spec.rb b/spec/ruby/library/uri/generic/component_spec.rb
new file mode 100644
index 0000000000..6fb83d7796
--- /dev/null
+++ b/spec/ruby/library/uri/generic/component_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#component" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic.component" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/default_port_spec.rb b/spec/ruby/library/uri/generic/default_port_spec.rb
new file mode 100644
index 0000000000..d1e0ce2d3f
--- /dev/null
+++ b/spec/ruby/library/uri/generic/default_port_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#default_port" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic.default_port" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/eql_spec.rb b/spec/ruby/library/uri/generic/eql_spec.rb
new file mode 100644
index 0000000000..65f9204a19
--- /dev/null
+++ b/spec/ruby/library/uri/generic/eql_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#eql?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/equal_value_spec.rb b/spec/ruby/library/uri/generic/equal_value_spec.rb
new file mode 100644
index 0000000000..f41b202498
--- /dev/null
+++ b/spec/ruby/library/uri/generic/equal_value_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#==" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/fragment_spec.rb b/spec/ruby/library/uri/generic/fragment_spec.rb
new file mode 100644
index 0000000000..de6f4e078d
--- /dev/null
+++ b/spec/ruby/library/uri/generic/fragment_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#fragment" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#fragment=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/hash_spec.rb b/spec/ruby/library/uri/generic/hash_spec.rb
new file mode 100644
index 0000000000..3410558067
--- /dev/null
+++ b/spec/ruby/library/uri/generic/hash_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#hash" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/hierarchical_spec.rb b/spec/ruby/library/uri/generic/hierarchical_spec.rb
new file mode 100644
index 0000000000..1c90dc4f8f
--- /dev/null
+++ b/spec/ruby/library/uri/generic/hierarchical_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#hierarchical?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/host_spec.rb b/spec/ruby/library/uri/generic/host_spec.rb
new file mode 100644
index 0000000000..6fb6c1c36a
--- /dev/null
+++ b/spec/ruby/library/uri/generic/host_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#host" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#host=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/inspect_spec.rb b/spec/ruby/library/uri/generic/inspect_spec.rb
new file mode 100644
index 0000000000..696c3308d4
--- /dev/null
+++ b/spec/ruby/library/uri/generic/inspect_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#inspect" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/merge_spec.rb b/spec/ruby/library/uri/generic/merge_spec.rb
new file mode 100644
index 0000000000..63642197e1
--- /dev/null
+++ b/spec/ruby/library/uri/generic/merge_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#merge" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#merge!" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/minus_spec.rb b/spec/ruby/library/uri/generic/minus_spec.rb
new file mode 100644
index 0000000000..3426a6068b
--- /dev/null
+++ b/spec/ruby/library/uri/generic/minus_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#-" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/normalize_spec.rb b/spec/ruby/library/uri/generic/normalize_spec.rb
new file mode 100644
index 0000000000..ac02b644d0
--- /dev/null
+++ b/spec/ruby/library/uri/generic/normalize_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#normalize" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#normalize!" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/opaque_spec.rb b/spec/ruby/library/uri/generic/opaque_spec.rb
new file mode 100644
index 0000000000..f418c220f2
--- /dev/null
+++ b/spec/ruby/library/uri/generic/opaque_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#opaque" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#opaque=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/password_spec.rb b/spec/ruby/library/uri/generic/password_spec.rb
new file mode 100644
index 0000000000..087db60fb9
--- /dev/null
+++ b/spec/ruby/library/uri/generic/password_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#password" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#password=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/path_spec.rb b/spec/ruby/library/uri/generic/path_spec.rb
new file mode 100644
index 0000000000..5ea60b5418
--- /dev/null
+++ b/spec/ruby/library/uri/generic/path_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#path" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#path=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/plus_spec.rb b/spec/ruby/library/uri/generic/plus_spec.rb
new file mode 100644
index 0000000000..3d1c031022
--- /dev/null
+++ b/spec/ruby/library/uri/generic/plus_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#+" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/port_spec.rb b/spec/ruby/library/uri/generic/port_spec.rb
new file mode 100644
index 0000000000..148e84ff14
--- /dev/null
+++ b/spec/ruby/library/uri/generic/port_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#port" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#port=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/query_spec.rb b/spec/ruby/library/uri/generic/query_spec.rb
new file mode 100644
index 0000000000..945fdc06a3
--- /dev/null
+++ b/spec/ruby/library/uri/generic/query_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#query" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#query=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/registry_spec.rb b/spec/ruby/library/uri/generic/registry_spec.rb
new file mode 100644
index 0000000000..6a48b25465
--- /dev/null
+++ b/spec/ruby/library/uri/generic/registry_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#registry" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#registry=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/relative_spec.rb b/spec/ruby/library/uri/generic/relative_spec.rb
new file mode 100644
index 0000000000..09730fa4eb
--- /dev/null
+++ b/spec/ruby/library/uri/generic/relative_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#relative?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/route_from_spec.rb b/spec/ruby/library/uri/generic/route_from_spec.rb
new file mode 100644
index 0000000000..03321cbf0d
--- /dev/null
+++ b/spec/ruby/library/uri/generic/route_from_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#route_from" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/route_to_spec.rb b/spec/ruby/library/uri/generic/route_to_spec.rb
new file mode 100644
index 0000000000..a12e1f7649
--- /dev/null
+++ b/spec/ruby/library/uri/generic/route_to_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#route_to" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/scheme_spec.rb b/spec/ruby/library/uri/generic/scheme_spec.rb
new file mode 100644
index 0000000000..fa3dfcb8aa
--- /dev/null
+++ b/spec/ruby/library/uri/generic/scheme_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#scheme" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#scheme=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/select_spec.rb b/spec/ruby/library/uri/generic/select_spec.rb
new file mode 100644
index 0000000000..5cc104f5dd
--- /dev/null
+++ b/spec/ruby/library/uri/generic/select_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#select" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_fragment_spec.rb b/spec/ruby/library/uri/generic/set_fragment_spec.rb
new file mode 100644
index 0000000000..cebad46585
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_fragment_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_fragment" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_host_spec.rb b/spec/ruby/library/uri/generic/set_host_spec.rb
new file mode 100644
index 0000000000..357b7a6889
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_host_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_host" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_opaque_spec.rb b/spec/ruby/library/uri/generic/set_opaque_spec.rb
new file mode 100644
index 0000000000..afd6597675
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_opaque_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_opaque" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_password_spec.rb b/spec/ruby/library/uri/generic/set_password_spec.rb
new file mode 100644
index 0000000000..15b4fdc37d
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_password_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_password" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_path_spec.rb b/spec/ruby/library/uri/generic/set_path_spec.rb
new file mode 100644
index 0000000000..b4366d789c
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_path_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_path" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_port_spec.rb b/spec/ruby/library/uri/generic/set_port_spec.rb
new file mode 100644
index 0000000000..aa65bb96e3
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_port_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_port" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_query_spec.rb b/spec/ruby/library/uri/generic/set_query_spec.rb
new file mode 100644
index 0000000000..b1c25e56ca
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_query_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_query" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_registry_spec.rb b/spec/ruby/library/uri/generic/set_registry_spec.rb
new file mode 100644
index 0000000000..602f868ac1
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_registry_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_registry" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_scheme_spec.rb b/spec/ruby/library/uri/generic/set_scheme_spec.rb
new file mode 100644
index 0000000000..e1a94c5b1a
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_scheme_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_scheme" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_user_spec.rb b/spec/ruby/library/uri/generic/set_user_spec.rb
new file mode 100644
index 0000000000..36a6ac9e85
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_user_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_user" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/set_userinfo_spec.rb b/spec/ruby/library/uri/generic/set_userinfo_spec.rb
new file mode 100644
index 0000000000..cbe80d9809
--- /dev/null
+++ b/spec/ruby/library/uri/generic/set_userinfo_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#set_userinfo" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/to_s_spec.rb b/spec/ruby/library/uri/generic/to_s_spec.rb
new file mode 100644
index 0000000000..c0a0f803ef
--- /dev/null
+++ b/spec/ruby/library/uri/generic/to_s_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#to_s" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/use_registry_spec.rb b/spec/ruby/library/uri/generic/use_registry_spec.rb
new file mode 100644
index 0000000000..4e7ae6a5cf
--- /dev/null
+++ b/spec/ruby/library/uri/generic/use_registry_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic.use_registry" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/user_spec.rb b/spec/ruby/library/uri/generic/user_spec.rb
new file mode 100644
index 0000000000..b785ef6879
--- /dev/null
+++ b/spec/ruby/library/uri/generic/user_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#user" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#user=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/generic/userinfo_spec.rb b/spec/ruby/library/uri/generic/userinfo_spec.rb
new file mode 100644
index 0000000000..5d0fc50b65
--- /dev/null
+++ b/spec/ruby/library/uri/generic/userinfo_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Generic#userinfo" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::Generic#userinfo=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/http/build_spec.rb b/spec/ruby/library/uri/http/build_spec.rb
new file mode 100644
index 0000000000..85103167e0
--- /dev/null
+++ b/spec/ruby/library/uri/http/build_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::HTTP.build" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/http/request_uri_spec.rb b/spec/ruby/library/uri/http/request_uri_spec.rb
new file mode 100644
index 0000000000..85d89aba77
--- /dev/null
+++ b/spec/ruby/library/uri/http/request_uri_spec.rb
@@ -0,0 +1,16 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::HTTP.request_uri" do
+ it "returns a string of the path + query" do
+ URI("http://reddit.com/r/ruby/").request_uri.should == "/r/ruby/"
+ URI("http://reddit.com/r/ruby/search?q=rubinius").request_uri.should == "/r/ruby/search?q=rubinius"
+ end
+
+ it "returns '/' if the path of the URI is blank" do
+ URI("http://ruby.reddit.com").request_uri.should == "/"
+ end
+end
+describe "URI::HTTP#request_uri" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/join_spec.rb b/spec/ruby/library/uri/join_spec.rb
new file mode 100644
index 0000000000..681ba45cc7
--- /dev/null
+++ b/spec/ruby/library/uri/join_spec.rb
@@ -0,0 +1,57 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.join" do
+ it "returns a URI object of the concatenation of a protocol and domain, and a path" do
+ URI.join("http://localhost/","main.rbx").should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "accepts URI objects" do
+ URI.join(URI("http://localhost/"),"main.rbx").should == URI.parse("http://localhost/main.rbx")
+ URI.join("http://localhost/",URI("main.rbx")).should == URI.parse("http://localhost/main.rbx")
+ URI.join(URI("http://localhost/"),URI("main.rbx")).should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "accepts string-like arguments with to_str" do
+ str = mock('string-like')
+ str.should_receive(:to_str).and_return("http://ruby-lang.org")
+ str2 = mock('string-like also')
+ str2.should_receive(:to_str).and_return("foo/bar")
+ URI.join(str, str2).should == URI.parse("http://ruby-lang.org/foo/bar")
+ end
+
+ it "raises an error if given no argument" do
+ lambda{ URI.join }.should raise_error
+ end
+
+ it "doesn't create redundant '/'s" do
+ URI.join("http://localhost/", "/main.rbx").should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "discards arguments given before an absolute uri" do
+ URI.join("http://localhost/a/b/c/d", "http://ruby-lang.com/foo", "bar").should == URI.parse("http://ruby-lang.com/bar")
+ end
+
+ it "resolves .. in paths" do
+ URI.join("http://localhost/a/b/c/d", "../../e/f", "g/h/../i").to_s.should == "http://localhost/a/e/g/i"
+ end
+end
+
+
+# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo/bar'))
+# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo', 'bar'))
+# assert_equal(URI.parse('http://foo/bar/'), URI.join('http://foo', 'bar/'))
+#
+# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', 'baz'))
+# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', '/baz'))
+# assert_equal(URI.parse('http://foo/baz/'), URI.join('http://foo', 'bar', '/baz/'))
+# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/', 'baz'))
+# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar', 'baz', 'hoge'))
+#
+# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/baz'))
+# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge'))
+# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge'))
+# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge'))
+# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge'))
+# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge'))
+# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge'))
diff --git a/spec/ruby/library/uri/ldap/attributes_spec.rb b/spec/ruby/library/uri/ldap/attributes_spec.rb
new file mode 100644
index 0000000000..2309de7c62
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/attributes_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#attributes" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::LDAP#attributes=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/build_spec.rb b/spec/ruby/library/uri/ldap/build_spec.rb
new file mode 100644
index 0000000000..99e2611b1f
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/build_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP.build" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/dn_spec.rb b/spec/ruby/library/uri/ldap/dn_spec.rb
new file mode 100644
index 0000000000..b1371611d3
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/dn_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#dn" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::LDAP#dn=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/extensions_spec.rb b/spec/ruby/library/uri/ldap/extensions_spec.rb
new file mode 100644
index 0000000000..2d9b09e6a7
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/extensions_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#extensions" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::LDAP#extensions=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/filter_spec.rb b/spec/ruby/library/uri/ldap/filter_spec.rb
new file mode 100644
index 0000000000..1f996339db
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/filter_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#filter" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::LDAP#filter=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/hierarchical_spec.rb b/spec/ruby/library/uri/ldap/hierarchical_spec.rb
new file mode 100644
index 0000000000..97c23a7f0c
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/hierarchical_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#hierarchical?" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/scope_spec.rb b/spec/ruby/library/uri/ldap/scope_spec.rb
new file mode 100644
index 0000000000..d4a02e08f0
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/scope_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#scope" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::LDAP#scope=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/set_attributes_spec.rb b/spec/ruby/library/uri/ldap/set_attributes_spec.rb
new file mode 100644
index 0000000000..1bbcb34837
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/set_attributes_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#set_attributes" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/set_dn_spec.rb b/spec/ruby/library/uri/ldap/set_dn_spec.rb
new file mode 100644
index 0000000000..abb640b585
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/set_dn_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#set_dn" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/set_extensions_spec.rb b/spec/ruby/library/uri/ldap/set_extensions_spec.rb
new file mode 100644
index 0000000000..5cd2077aab
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/set_extensions_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#set_extensions" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/set_filter_spec.rb b/spec/ruby/library/uri/ldap/set_filter_spec.rb
new file mode 100644
index 0000000000..f1b8e5e595
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/set_filter_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#set_filter" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/ldap/set_scope_spec.rb b/spec/ruby/library/uri/ldap/set_scope_spec.rb
new file mode 100644
index 0000000000..5a0841cfd8
--- /dev/null
+++ b/spec/ruby/library/uri/ldap/set_scope_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::LDAP#set_scope" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/build_spec.rb b/spec/ruby/library/uri/mailto/build_spec.rb
new file mode 100644
index 0000000000..cb57f0c794
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/build_spec.rb
@@ -0,0 +1,98 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Mailto.build" do
+ it "conforms to the MatzRuby tests" do
+ ok = []
+ bad = []
+
+ # RFC2368, 6. Examples
+ # mailto:chris@example.com
+ ok << ["mailto:chris@example.com"]
+ ok[-1] << ["chris@example.com", nil]
+ ok[-1] << {to: "chris@example.com"}
+
+ # mailto:infobot@example.com?subject=current-issue
+ ok << ["mailto:infobot@example.com?subject=current-issue"]
+ ok[-1] << ["infobot@example.com", ["subject=current-issue"]]
+ ok[-1] << {to: "infobot@example.com",
+ headers: ["subject=current-issue"]}
+
+ # mailto:infobot@example.com?body=send%20current-issue
+ ok << ["mailto:infobot@example.com?body=send%20current-issue"]
+ ok[-1] << ["infobot@example.com", ["body=send%20current-issue"]]
+ ok[-1] << {to: "infobot@example.com",
+ headers: ["body=send%20current-issue"]}
+
+ # mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index
+ ok << ["mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index"]
+ ok[-1] << ["infobot@example.com",
+ ["body=send%20current-issue%0D%0Asend%20index"]]
+ ok[-1] << {to: "infobot@example.com",
+ headers: ["body=send%20current-issue%0D%0Asend%20index"]}
+
+ # mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com
+ ok << ["mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com"]
+ ok[-1] << ["foobar@example.com",
+ ["In-Reply-To=%3c3469A91.D10AF4C@example.com"]]
+ ok[-1] << {to: "foobar@example.com",
+ headers: ["In-Reply-To=%3c3469A91.D10AF4C@example.com"]}
+
+ # mailto:majordomo@example.com?body=subscribe%20bamboo-l
+ ok << ["mailto:majordomo@example.com?body=subscribe%20bamboo-l"]
+ ok[-1] << ["majordomo@example.com", ["body=subscribe%20bamboo-l"]]
+ ok[-1] << {to: "majordomo@example.com",
+ headers: ["body=subscribe%20bamboo-l"]}
+
+ # mailto:joe@example.com?cc=bob@example.com&body=hello
+ ok << ["mailto:joe@example.com?cc=bob@example.com&body=hello"]
+ ok[-1] << ["joe@example.com", ["cc=bob@example.com", "body=hello"]]
+ ok[-1] << {to: "joe@example.com",
+ headers: ["cc=bob@example.com", "body=hello"]}
+
+ # mailto:?to=joe@example.com&cc=bob@example.com&body=hello
+ ok << ["mailto:?to=joe@example.com&cc=bob@example.com&body=hello"]
+ ok[-1] << [nil,
+ ["to=joe@example.com", "cc=bob@example.com", "body=hello"]]
+ ok[-1] << {headers: ["to=joe@example.com", "cc=bob@example.com", "body=hello"]}
+
+ # mailto:gorby%25kremvax@example.com
+ ok << ["mailto:gorby%25kremvax@example.com"]
+ ok[-1] << ["gorby%25kremvax@example.com", nil]
+ ok[-1] << {to: "gorby%25kremvax@example.com"}
+
+ # mailto:unlikely%3Faddress@example.com?blat=foop
+ ok << ["mailto:unlikely%3Faddress@example.com?blat=foop"]
+ ok[-1] << ["unlikely%3Faddress@example.com", ["blat=foop"]]
+ ok[-1] << {to: "unlikely%3Faddress@example.com",
+ headers: ["blat=foop"]}
+
+ ok_all = ok.flatten.join("\0")
+
+ # mailto:joe@example.com?cc=bob@example.com?body=hello ; WRONG!
+ bad << ["joe@example.com", ["cc=bob@example.com?body=hello"]]
+
+ # mailto:javascript:alert()
+ bad << ["javascript:alert()", []]
+
+ # '=' which is in hname or hvalue is wrong.
+ bad << ["foo@example.jp?subject=1+1=2", []]
+
+ ok.each do |x|
+ URI::MailTo.build(x[1]).to_s.should == x[0]
+ URI::MailTo.build(x[2]).to_s.should == x[0]
+ end
+
+ bad.each do |x|
+ lambda { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError)
+ end
+
+ ok.flatten.join("\0").should == ok_all
+ end
+end
+
+
+
+describe "URI::MailTo.build" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/headers_spec.rb b/spec/ruby/library/uri/mailto/headers_spec.rb
new file mode 100644
index 0000000000..844fdee714
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/headers_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#headers" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::MailTo#headers=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/set_headers_spec.rb b/spec/ruby/library/uri/mailto/set_headers_spec.rb
new file mode 100644
index 0000000000..c1384d5dca
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/set_headers_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#set_headers" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/set_to_spec.rb b/spec/ruby/library/uri/mailto/set_to_spec.rb
new file mode 100644
index 0000000000..a8351a2092
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/set_to_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#set_to" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/to_mailtext_spec.rb b/spec/ruby/library/uri/mailto/to_mailtext_spec.rb
new file mode 100644
index 0000000000..4c7a48874f
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/to_mailtext_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#to_mailtext" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb b/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb
new file mode 100644
index 0000000000..e769f62deb
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/to_rfc822text_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#to_rfc822text" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/to_s_spec.rb b/spec/ruby/library/uri/mailto/to_s_spec.rb
new file mode 100644
index 0000000000..2709d19d27
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/to_s_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#to_s" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/mailto/to_spec.rb b/spec/ruby/library/uri/mailto/to_spec.rb
new file mode 100644
index 0000000000..f30d23dd53
--- /dev/null
+++ b/spec/ruby/library/uri/mailto/to_spec.rb
@@ -0,0 +1,10 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::MailTo#to" do
+ it "needs to be reviewed for spec completeness"
+end
+
+describe "URI::MailTo#to=" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/merge_spec.rb b/spec/ruby/library/uri/merge_spec.rb
new file mode 100644
index 0000000000..c62e80d6b2
--- /dev/null
+++ b/spec/ruby/library/uri/merge_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI#merge" do
+ it "returns the receiver and the argument, joined as per URI.join" do
+ URI("http://localhost/").merge("main.rbx").should == URI.parse("http://localhost/main.rbx")
+ URI("http://localhost/a/b/c/d").merge("http://ruby-lang.com/foo").should == URI.parse("http://ruby-lang.com/foo")
+ URI("http://localhost/a/b/c/d").merge("../../e/f").to_s.should == "http://localhost/a/e/f"
+ end
+
+ it "accepts URI objects as argument" do
+ URI("http://localhost/").merge(URI("main.rbx")).should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "accepts a string-like argument" do
+ str = mock('string-like')
+ str.should_receive(:to_str).and_return("foo/bar")
+ URI("http://localhost/").merge(str).should == URI.parse("http://localhost/foo/bar")
+ end
+end
diff --git a/spec/ruby/library/uri/normalize_spec.rb b/spec/ruby/library/uri/normalize_spec.rb
new file mode 100644
index 0000000000..079a9ad61d
--- /dev/null
+++ b/spec/ruby/library/uri/normalize_spec.rb
@@ -0,0 +1,35 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/normalization', __FILE__)
+require 'uri'
+
+describe "URI#normalize" do
+ it "adds a / onto the end of the URI if the path is blank" do
+ no_path = URI("http://example.com")
+ no_path.to_s.should_not == "http://example.com/"
+ no_path.normalize.to_s.should == "http://example.com/"
+ end
+
+ it "downcases the host of the URI" do
+ uri = URI("http://exAMPLE.cOm/")
+ uri.to_s.should_not == "http://example.com/"
+ uri.normalize.to_s.should == "http://example.com/"
+ end
+
+ # The previous tests are included by the one below
+
+ quarantine! do # Quarantined until redmine:2542 is accepted
+ it "respects RFC 3986" do
+ URISpec::NORMALIZED_FORMS.each do |form|
+ normal_uri = URI(form[:normalized])
+ normalized = normal_uri.normalize.to_s
+ normal_uri.to_s.should == normalized
+ form[:equivalent].each do |same|
+ URI(same).normalize.to_s.should == normalized
+ end
+ form[:different].each do |other|
+ URI(other).normalize.to_s.should_not == normalized
+ end
+ end
+ end
+ end
+end
diff --git a/spec/ruby/library/uri/parse_spec.rb b/spec/ruby/library/uri/parse_spec.rb
new file mode 100644
index 0000000000..4aa84ae2ee
--- /dev/null
+++ b/spec/ruby/library/uri/parse_spec.rb
@@ -0,0 +1,203 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+describe "URI.parse" do
+
+ it "returns a URI::HTTP object when parsing an HTTP URI" do
+ URI.parse("http://www.example.com/").should be_kind_of(URI::HTTP)
+ end
+
+ it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do
+ # general case
+ URISpec.components(URI.parse("http://user:pass@example.com/path/?query=val&q2=val2#fragment")).should == {
+ scheme: "http",
+ userinfo: "user:pass",
+ host: "example.com",
+ port: 80,
+ path: "/path/",
+ query: "query=val&q2=val2",
+ fragment: "fragment"
+ }
+
+ # multiple paths
+ URISpec.components(URI.parse("http://a/b/c/d;p?q")).should == {
+ scheme: "http",
+ userinfo: nil,
+ host: "a",
+ port: 80,
+ path: "/b/c/d;p",
+ query: "q",
+ fragment: nil
+ }
+
+ # multi-level domain
+ URISpec.components(URI.parse('http://www.math.uio.no/faq/compression-faq/part1.html')).should == {
+ scheme: "http",
+ userinfo: nil,
+ host: "www.math.uio.no",
+ port: 80,
+ path: "/faq/compression-faq/part1.html",
+ query: nil,
+ fragment: nil
+ }
+ end
+
+ it "parses out the port number of a URI, when given" do
+ URI.parse("http://example.com:8080/").port.should == 8080
+ end
+
+ it "returns a URI::HTTPS object when parsing an HTTPS URI" do
+ URI.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS)
+ end
+
+ it "sets the port of a parsed https URI to 443 by default" do
+ URI.parse("https://example.com/").port.should == 443
+ end
+
+ it "populates the components of a parsed URI::FTP object" do
+ # generic, empty password.
+ url = URI.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i")
+ url.should be_kind_of(URI::FTP)
+ URISpec.components(url).should == {
+ scheme: "ftp",
+ userinfo: "anonymous",
+ host: "ruby-lang.org",
+ port: 21,
+ path: "pub/ruby/1.8/ruby-1.8.6.tar.bz2",
+ typecode: "i"
+ }
+
+ # multidomain, no user or password
+ url = URI.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt')
+ url.should be_kind_of(URI::FTP)
+ URISpec.components(url).should == {
+ scheme: "ftp",
+ userinfo: nil,
+ host: "ftp.is.co.za",
+ port: 21,
+ path: "rfc/rfc1808.txt",
+ typecode: nil
+ }
+
+ # empty user
+ url = URI.parse('ftp://:pass@localhost/')
+ url.should be_kind_of(URI::FTP)
+ URISpec.components(url).should == {
+ scheme: "ftp",
+ userinfo: ":pass",
+ host: "localhost",
+ port: 21,
+ path: "",
+ typecode: nil
+ }
+ url.password.should == "pass"
+ end
+
+ it "returns a URI::LDAP object when parsing an LDAP URI" do
+ #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like
+ ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo }
+ ldap_uris.each do |ldap_uri|
+ URI.parse(ldap_uri).should be_kind_of(URI::LDAP)
+ end
+ end
+
+ it "populates the components of a parsed URI::LDAP object" do
+ URISpec.components(URI.parse("ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress?scope?filter?extensions")).should == {
+ scheme: "ldap",
+ host: "ldap.itd.umich.edu",
+ port: 389,
+ dn: "o=University%20of%20Michigan,c=US",
+ attributes: "postalAddress",
+ scope: "scope",
+ filter: "filter",
+ extensions: "extensions"
+ }
+ end
+
+ it "returns a URI::MailTo object when passed a mailto URI" do
+ URI.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo)
+ end
+
+ it "populates the components of a parsed URI::MailTo object" do
+ URISpec.components(URI.parse("mailto:spam@mailinator.com?subject=Discounts%20On%20Imported%20methods!!!&body=Exciting%20offer")).should == {
+ scheme: "mailto",
+ to: "spam@mailinator.com",
+ headers: [["subject","Discounts%20On%20Imported%20methods!!!"],
+ ["body", "Exciting%20offer"]]
+ }
+ end
+
+ # TODO
+ # Test registry
+ it "does its best to extract components from URI::Generic objects" do
+ # generic
+ URISpec.components(URI("scheme://userinfo@host/path?query#fragment")).should == {
+ scheme: "scheme",
+ userinfo: "userinfo",
+ host: "host",
+ port: nil,
+ path: "/path",
+ query: "query",
+ fragment: "fragment",
+ registry: nil,
+ opaque: nil
+ }
+
+ # gopher
+ gopher = URI.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles')
+ gopher.should be_kind_of(URI::Generic)
+
+ URISpec.components(gopher).should == {
+ scheme: "gopher",
+ userinfo: nil,
+ host: "spinaltap.micro.umn.edu",
+ port: nil,
+ path: "/00/Weather/California/Los%20Angeles",
+ query: nil,
+ fragment: nil,
+ registry: nil,
+ opaque: nil
+ }
+
+ # news
+ news = URI.parse('news:comp.infosystems.www.servers.unix')
+ news.should be_kind_of(URI::Generic)
+ URISpec.components(news).should == {
+ scheme: "news",
+ userinfo: nil,
+ host: nil,
+ port: nil,
+ path: nil,
+ query: nil,
+ fragment: nil,
+ registry: nil,
+ opaque: "comp.infosystems.www.servers.unix"
+ }
+
+ # telnet
+ telnet = URI.parse('telnet://melvyl.ucop.edu/')
+ telnet.should be_kind_of(URI::Generic)
+ URISpec.components(telnet).should == {
+ scheme: "telnet",
+ userinfo: nil,
+ host: "melvyl.ucop.edu",
+ port: nil,
+ path: "/",
+ query: nil,
+ fragment: nil,
+ registry: nil,
+ opaque: nil
+ }
+
+ # files
+ file_l = URI.parse('file:///foo/bar.txt')
+ file_l.should be_kind_of(URI::Generic)
+ file = URI.parse('file:/foo/bar.txt')
+ file.should be_kind_of(URI::Generic)
+ end
+
+ it "doesn't raise errors on URIs which has underscore in reg_name" do
+ URI.parse('http://a_b:80/').host.should == "a_b"
+ URI.parse('http://a_b/').host.should == "a_b"
+ end
+end
diff --git a/spec/ruby/library/uri/parser/escape_spec.rb b/spec/ruby/library/uri/parser/escape_spec.rb
new file mode 100644
index 0000000000..8682e0ebce
--- /dev/null
+++ b/spec/ruby/library/uri/parser/escape_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Parser#escape" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/parser/extract_spec.rb b/spec/ruby/library/uri/parser/extract_spec.rb
new file mode 100644
index 0000000000..5dac947060
--- /dev/null
+++ b/spec/ruby/library/uri/parser/extract_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/extract', __FILE__)
+require 'uri'
+
+describe "URI::Parser#extract" do
+ it_behaves_like :uri_extract, :extract, URI::Parser.new
+end
diff --git a/spec/ruby/library/uri/parser/inspect_spec.rb b/spec/ruby/library/uri/parser/inspect_spec.rb
new file mode 100644
index 0000000000..2eaeeeafee
--- /dev/null
+++ b/spec/ruby/library/uri/parser/inspect_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Parser#split" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/parser/join_spec.rb b/spec/ruby/library/uri/parser/join_spec.rb
new file mode 100644
index 0000000000..1800a16236
--- /dev/null
+++ b/spec/ruby/library/uri/parser/join_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../shared/join', __FILE__)
+require 'uri'
+
+describe "URI::Parser#join" do
+ it_behaves_like :uri_join, :join, URI::Parser.new
+end
diff --git a/spec/ruby/library/uri/parser/make_regexp_spec.rb b/spec/ruby/library/uri/parser/make_regexp_spec.rb
new file mode 100644
index 0000000000..e27f0d14db
--- /dev/null
+++ b/spec/ruby/library/uri/parser/make_regexp_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Parser#make_regexp" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/parser/parse_spec.rb b/spec/ruby/library/uri/parser/parse_spec.rb
new file mode 100644
index 0000000000..76c1970645
--- /dev/null
+++ b/spec/ruby/library/uri/parser/parse_spec.rb
@@ -0,0 +1,7 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+require File.expand_path('../../shared/parse', __FILE__)
+
+describe "URI::Parser#parse" do
+ it_behaves_like :uri_parse, :parse, URI::Parser.new
+end
diff --git a/spec/ruby/library/uri/parser/split_spec.rb b/spec/ruby/library/uri/parser/split_spec.rb
new file mode 100644
index 0000000000..2eaeeeafee
--- /dev/null
+++ b/spec/ruby/library/uri/parser/split_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Parser#split" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/parser/unescape_spec.rb b/spec/ruby/library/uri/parser/unescape_spec.rb
new file mode 100644
index 0000000000..8ffc534226
--- /dev/null
+++ b/spec/ruby/library/uri/parser/unescape_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Parser#unescape" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/plus_spec.rb b/spec/ruby/library/uri/plus_spec.rb
new file mode 100644
index 0000000000..45c1aa5e57
--- /dev/null
+++ b/spec/ruby/library/uri/plus_spec.rb
@@ -0,0 +1,459 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+#an alias of URI#merge
+describe "URI#+" do
+ it "replaces the end of the path of the URI when added to a string that looks like a relative path" do
+ (URI('http://foo') + 'bar').should == URI("http://foo/bar")
+ (URI('http://foo/baz') + 'bar').should == URI("http://foo/bar")
+ (URI('http://foo/baz/') + 'bar').should == URI("http://foo/baz/bar")
+ (URI('mailto:foo@example.com') + "#bar").should == URI("mailto:foo@example.com#bar")
+ end
+
+ it "replaces the entire path of the URI when added to a string that begins with a /" do
+ (URI('http://foo/baz/') + '/bar').should == URI("http://foo/bar")
+ end
+
+ it "replaces the entire url when added to a string that looks like a full url" do
+ (URI.parse('http://a/b') + 'http://x/y').should == URI("http://x/y")
+ (URI.parse('telnet:example.com') + 'http://x/y').should == URI("http://x/y")
+ end
+
+ it "canonicalizes the URI's path, removing ../'s" do
+ (URI.parse('http://a/b/c/../') + "./").should == URI("http://a/b/")
+ (URI.parse('http://a/b/c/../') + ".").should == URI("http://a/b/")
+ (URI.parse('http://a/b/c/') + "../").should == URI("http://a/b/")
+ (URI.parse('http://a/b/c/../../') + "./").should == URI("http://a/")
+ (URI.parse('http://a/b/c/') + "../e/").should == URI("http://a/b/e/")
+ (URI.parse('http://a/b/c/') + "../e/../").should == URI("http://a/b/")
+ (URI.parse('http://a/b/../c/') + ".").should == URI("http://a/c/")
+
+ (URI.parse('http://a/b/c/../../../') + ".").should == URI("http://a/")
+ end
+
+ it "doesn't conconicalize the path when adding to the empty string" do
+ (URI.parse('http://a/b/c/../') + "").should == URI("http://a/b/c/../")
+ end
+
+ it "raises a URI::BadURIError when adding two relative URIs" do
+ lambda {URI.parse('a/b/c') + "d"}.should raise_error(URI::BadURIError)
+ end
+
+ #Todo: make more BDD?
+ it "conforms to the merge specifications from rfc 2396" do
+ @url = 'http://a/b/c/d;p?q'
+ @base_url = URI.parse(@url)
+
+# http://a/b/c/d;p?q
+# g:h = g:h
+ url = @base_url.merge('g:h')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g:h'
+ url = @base_url.route_to('g:h')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g:h'
+
+# http://a/b/c/d;p?q
+# g = http://a/b/c/g
+ url = @base_url.merge('g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g'
+ url = @base_url.route_to('http://a/b/c/g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g'
+
+# http://a/b/c/d;p?q
+# ./g = http://a/b/c/g
+ url = @base_url.merge('./g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g'
+ url = @base_url.route_to('http://a/b/c/g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == './g' # ok
+ url.to_s.should == 'g'
+
+# http://a/b/c/d;p?q
+# g/ = http://a/b/c/g/
+ url = @base_url.merge('g/')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g/'
+ url = @base_url.route_to('http://a/b/c/g/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g/'
+
+# http://a/b/c/d;p?q
+# /g = http://a/g
+ url = @base_url.merge('/g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/g'
+ url = @base_url.route_to('http://a/g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == '/g' # ok
+ url.to_s.should == '../../g'
+
+# http://a/b/c/d;p?q
+# //g = http://g
+ url = @base_url.merge('//g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://g'
+ url = @base_url.route_to('http://g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '//g'
+
+# http://a/b/c/d;p?q
+# ?y = http://a/b/c/?y
+ url = @base_url.merge('?y')
+ url.should be_kind_of(URI::HTTP)
+
+ url.to_s.should == 'http://a/b/c/d;p?y'
+
+ url = @base_url.route_to('http://a/b/c/?y')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '?y'
+
+# http://a/b/c/d;p?q
+# g?y = http://a/b/c/g?y
+ url = @base_url.merge('g?y')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g?y'
+ url = @base_url.route_to('http://a/b/c/g?y')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g?y'
+
+# http://a/b/c/d;p?q
+# #s = (current document)#s
+ url = @base_url.merge('#s')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == @base_url.to_s + '#s'
+ url = @base_url.route_to(@base_url.to_s + '#s')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '#s'
+
+# http://a/b/c/d;p?q
+# g#s = http://a/b/c/g#s
+ url = @base_url.merge('g#s')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g#s'
+ url = @base_url.route_to('http://a/b/c/g#s')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g#s'
+
+# http://a/b/c/d;p?q
+# g?y#s = http://a/b/c/g?y#s
+ url = @base_url.merge('g?y#s')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g?y#s'
+ url = @base_url.route_to('http://a/b/c/g?y#s')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g?y#s'
+
+# http://a/b/c/d;p?q
+# ;x = http://a/b/c/;x
+ url = @base_url.merge(';x')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/;x'
+ url = @base_url.route_to('http://a/b/c/;x')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == ';x'
+
+# http://a/b/c/d;p?q
+# g;x = http://a/b/c/g;x
+ url = @base_url.merge('g;x')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g;x'
+ url = @base_url.route_to('http://a/b/c/g;x')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g;x'
+
+# http://a/b/c/d;p?q
+# g;x?y#s = http://a/b/c/g;x?y#s
+ url = @base_url.merge('g;x?y#s')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g;x?y#s'
+ url = @base_url.route_to('http://a/b/c/g;x?y#s')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g;x?y#s'
+
+# http://a/b/c/d;p?q
+# . = http://a/b/c/
+ url = @base_url.merge('.')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/'
+ url = @base_url.route_to('http://a/b/c/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == '.' # ok
+ url.to_s.should == './'
+
+# http://a/b/c/d;p?q
+# ./ = http://a/b/c/
+ url = @base_url.merge('./')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/'
+ url = @base_url.route_to('http://a/b/c/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == './'
+
+# http://a/b/c/d;p?q
+# .. = http://a/b/
+ url = @base_url.merge('..')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/'
+ url = @base_url.route_to('http://a/b/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == '..' # ok
+ url.to_s.should == '../'
+
+# http://a/b/c/d;p?q
+# ../ = http://a/b/
+ url = @base_url.merge('../')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/'
+ url = @base_url.route_to('http://a/b/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '../'
+
+# http://a/b/c/d;p?q
+# ../g = http://a/b/g
+ url = @base_url.merge('../g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/g'
+ url = @base_url.route_to('http://a/b/g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '../g'
+
+# http://a/b/c/d;p?q
+# ../.. = http://a/
+ url = @base_url.merge('../..')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/'
+ url = @base_url.route_to('http://a/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == '../..' # ok
+ url.to_s.should == '../../'
+
+# http://a/b/c/d;p?q
+# ../../ = http://a/
+ url = @base_url.merge('../../')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/'
+ url = @base_url.route_to('http://a/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '../../'
+
+# http://a/b/c/d;p?q
+# ../../g = http://a/g
+ url = @base_url.merge('../../g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/g'
+ url = @base_url.route_to('http://a/g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '../../g'
+
+# http://a/b/c/d;p?q
+# <> = (current document)
+ url = @base_url.merge('')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/d;p?q'
+ url = @base_url.route_to('http://a/b/c/d;p?q')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == ''
+
+# http://a/b/c/d;p?q
+# /./g = http://a/./g
+ url = @base_url.merge('/./g')
+ url.should be_kind_of(URI::HTTP)
+
+ url.to_s.should == 'http://a/g'
+
+ url = @base_url.route_to('http://a/./g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '/./g'
+
+# http://a/b/c/d;p?q
+# /../g = http://a/../g
+ url = @base_url.merge('/../g')
+ url.should be_kind_of(URI::HTTP)
+
+ url.to_s.should == 'http://a/g'
+
+ url = @base_url.route_to('http://a/../g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '/../g'
+
+# http://a/b/c/d;p?q
+# g. = http://a/b/c/g.
+ url = @base_url.merge('g.')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g.'
+ url = @base_url.route_to('http://a/b/c/g.')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g.'
+
+# http://a/b/c/d;p?q
+# .g = http://a/b/c/.g
+ url = @base_url.merge('.g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/.g'
+ url = @base_url.route_to('http://a/b/c/.g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '.g'
+
+# http://a/b/c/d;p?q
+# g.. = http://a/b/c/g..
+ url = @base_url.merge('g..')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g..'
+ url = @base_url.route_to('http://a/b/c/g..')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g..'
+
+# http://a/b/c/d;p?q
+# ..g = http://a/b/c/..g
+ url = @base_url.merge('..g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/..g'
+ url = @base_url.route_to('http://a/b/c/..g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == '..g'
+
+# http://a/b/c/d;p?q
+# ../../../g = http://a/../g
+ url = @base_url.merge('../../../g')
+ url.should be_kind_of(URI::HTTP)
+
+ url.to_s.should == 'http://a/g'
+
+ url = @base_url.route_to('http://a/../g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == '../../../g' # ok? yes, it confuses you
+ url.to_s.should == '/../g' # and it is clearly
+
+# http://a/b/c/d;p?q
+# ../../../../g = http://a/../../g
+ url = @base_url.merge('../../../../g')
+ url.should be_kind_of(URI::HTTP)
+
+ url.to_s.should == 'http://a/g'
+
+ url = @base_url.route_to('http://a/../../g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == '../../../../g' # ok? yes, it confuses you
+ url.to_s.should == '/../../g' # and it is clearly
+
+# http://a/b/c/d;p?q
+# ./../g = http://a/b/g
+ url = @base_url.merge('./../g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/g'
+ url = @base_url.route_to('http://a/b/g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == './../g' # ok
+ url.to_s.should == '../g'
+
+# http://a/b/c/d;p?q
+# ./g/. = http://a/b/c/g/
+ url = @base_url.merge('./g/.')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g/'
+ url = @base_url.route_to('http://a/b/c/g/')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == './g/.' # ok
+ url.to_s.should == 'g/'
+
+# http://a/b/c/d;p?q
+# g/./h = http://a/b/c/g/h
+ url = @base_url.merge('g/./h')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g/h'
+ url = @base_url.route_to('http://a/b/c/g/h')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == 'g/./h' # ok
+ url.to_s.should == 'g/h'
+
+# http://a/b/c/d;p?q
+# g/../h = http://a/b/c/h
+ url = @base_url.merge('g/../h')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/h'
+ url = @base_url.route_to('http://a/b/c/h')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == 'g/../h' # ok
+ url.to_s.should == 'h'
+
+# http://a/b/c/d;p?q
+# g;x=1/./y = http://a/b/c/g;x=1/y
+ url = @base_url.merge('g;x=1/./y')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g;x=1/y'
+ url = @base_url.route_to('http://a/b/c/g;x=1/y')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == 'g;x=1/./y' # ok
+ url.to_s.should == 'g;x=1/y'
+
+# http://a/b/c/d;p?q
+# g;x=1/../y = http://a/b/c/y
+ url = @base_url.merge('g;x=1/../y')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/y'
+ url = @base_url.route_to('http://a/b/c/y')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should_not == 'g;x=1/../y' # ok
+ url.to_s.should == 'y'
+
+# http://a/b/c/d;p?q
+# g?y/./x = http://a/b/c/g?y/./x
+ url = @base_url.merge('g?y/./x')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g?y/./x'
+ url = @base_url.route_to('http://a/b/c/g?y/./x')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g?y/./x'
+
+# http://a/b/c/d;p?q
+# g?y/../x = http://a/b/c/g?y/../x
+ url = @base_url.merge('g?y/../x')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g?y/../x'
+ url = @base_url.route_to('http://a/b/c/g?y/../x')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g?y/../x'
+
+# http://a/b/c/d;p?q
+# g#s/./x = http://a/b/c/g#s/./x
+ url = @base_url.merge('g#s/./x')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g#s/./x'
+ url = @base_url.route_to('http://a/b/c/g#s/./x')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g#s/./x'
+
+# http://a/b/c/d;p?q
+# g#s/../x = http://a/b/c/g#s/../x
+ url = @base_url.merge('g#s/../x')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http://a/b/c/g#s/../x'
+ url = @base_url.route_to('http://a/b/c/g#s/../x')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'g#s/../x'
+
+# http://a/b/c/d;p?q
+# http:g = http:g ; for validating parsers
+# | http://a/b/c/g ; for backwards compatibility
+ url = @base_url.merge('http:g')
+ url.should be_kind_of(URI::HTTP)
+ url.to_s.should == 'http:g'
+ url = @base_url.route_to('http:g')
+ url.should be_kind_of(URI::Generic)
+ url.to_s.should == 'http:g'
+ end
+end
+
+#TODO: incorporate these tests:
+#
+# u = URI.parse('http://foo/bar/baz')
+# assert_equal(nil, u.merge!(""))
+# assert_equal(nil, u.merge!(u))
+# assert(nil != u.merge!("."))
+# assert_equal('http://foo/bar/', u.to_s)
+# assert(nil != u.merge!("../baz"))
+# assert_equal('http://foo/baz', u.to_s)
diff --git a/spec/ruby/library/uri/regexp_spec.rb b/spec/ruby/library/uri/regexp_spec.rb
new file mode 100644
index 0000000000..cf63507013
--- /dev/null
+++ b/spec/ruby/library/uri/regexp_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+#I'm more or less ok with these limited tests, as the more extensive extract tests
+#use URI.regexp
+describe "URI.regexp" do
+ it "behaves according to the MatzRuby tests" do
+ URI.regexp.should == URI.regexp
+ 'x http:// x'.slice(URI.regexp).should == 'http://'
+ 'x http:// x'.slice(URI.regexp(['http'])).should == 'http://'
+ 'x http:// x ftp://'.slice(URI.regexp(['http'])).should == 'http://'
+ 'http://'.slice(URI.regexp([])).should == nil
+ ''.slice(URI.regexp).should == nil
+ 'xxxx'.slice(URI.regexp).should == nil
+ ':'.slice(URI.regexp).should == nil
+ 'From:'.slice(URI.regexp).should == 'From:'
+ end
+end
diff --git a/spec/ruby/library/uri/route_from_spec.rb b/spec/ruby/library/uri/route_from_spec.rb
new file mode 100644
index 0000000000..11a2c44f90
--- /dev/null
+++ b/spec/ruby/library/uri/route_from_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI#route_from" do
+
+ #this could be split out a good bit better
+ it "gives the minimal difference between the current URI and the target" do
+ URI("http://example.com/a.html").route_from('http://example.com/a.html').to_s.should == ""
+ URI("http://example.com/a.html").route_from('http://example.com/b.html').to_s.should == "a.html"
+ URI("http://example.com/a/").route_from('http://example.com/b/').to_s.should == "../a/"
+ URI("http://example.com/b/").route_from('http://example.com/a/c').to_s.should == "../b/"
+ URI("http://example.com/b/").route_from('http://example.com/a/b/').to_s.should == "../../b/"
+ URI("http://example.com/b/").route_from('http://EXAMPLE.cOm/a/b/').to_s.should == "../../b/"
+ URI("http://example.net/b/").route_from('http://example.com/a/b/').to_s.should == "//example.net/b/"
+ URI("mailto:foo@example.com#bar").route_from('mailto:foo@example.com').to_s.should == "#bar"
+ end
+
+ it "accepts a string-like argument" do
+ str = mock('string-like')
+ str.should_receive(:to_str).and_return("http://example.com/b.html")
+ URI("http://example.com/a.html").route_from(str).to_s.should == "a.html"
+ end
+end
diff --git a/spec/ruby/library/uri/route_to_spec.rb b/spec/ruby/library/uri/route_to_spec.rb
new file mode 100644
index 0000000000..2eb68afdfd
--- /dev/null
+++ b/spec/ruby/library/uri/route_to_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI#route_to" do
+
+ #this could be split out a good bit better
+ it "gives the minimal difference between the current URI and the target" do
+ URI("http://example.com/a.html").route_to('http://example.com/a.html').to_s.should == ""
+ URI("http://example.com/a.html").route_to('http://example.com/b.html').to_s.should == "b.html"
+ URI("http://example.com/a/").route_to('http://example.com/b/').to_s.should == "../b/"
+ URI("http://example.com/a/c").route_to('http://example.com/b/').to_s.should == "../b/"
+ URI("http://example.com/a/b/").route_to('http://example.com/b/').to_s.should == "../../b/"
+ URI("http://example.com/a/b/").route_to('http://EXAMPLE.cOm/b/').to_s.should == "../../b/"
+ URI("http://example.com/a/b/").route_to('http://example.net/b/').to_s.should == "//example.net/b/"
+ URI("mailto:foo@example.com").route_to('mailto:foo@example.com#bar').to_s.should == "#bar"
+
+ #this was a little surprising to me
+ URI("mailto:foo@example.com#bar").route_to('mailto:foo@example.com').to_s.should == ""
+ end
+
+ it "accepts a string-like argument" do
+ str = mock('string-like')
+ str.should_receive(:to_str).and_return("http://example.com/b.html")
+ URI("http://example.com/a.html").route_to(str).to_s.should == "b.html"
+ end
+end
diff --git a/spec/ruby/library/uri/select_spec.rb b/spec/ruby/library/uri/select_spec.rb
new file mode 100644
index 0000000000..46474757cc
--- /dev/null
+++ b/spec/ruby/library/uri/select_spec.rb
@@ -0,0 +1,31 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI#select" do
+ it "takes any number of component names as symbols, and returns an array of those components" do
+ URI("http://host:8080/path/").select.should == []
+ URI("http://host:8080/path/").select(:scheme,:host,:port,:path).should == [
+ "http","host",8080,"/path/"]
+ end
+
+ it "returns nil for any valid component that isn't set and doesn't have a default" do
+ uri = URI("http://host")
+ uri.select(:userinfo, :query, :fragment).should == [nil] * 3
+ uri.select(:port, :path).should == [80, '']
+ end
+
+ it "raises an ArgumentError if a component is requested that isn't valid under the given scheme" do
+ [
+ lambda {URI("mailto:spam@mailinator.com").select(:path)},
+ lambda {URI("http://blog.blag.web").select(:typecode)},
+ ].each do |select_lambda|
+ select_lambda.should raise_error(ArgumentError)
+ end
+ end
+
+ it "raises an ArgumentError if given strings rather than symbols" do
+ lambda {
+ URI("http://host:8080/path/").select("scheme","host","port",'path')
+ }.should raise_error(ArgumentError)
+ end
+end
diff --git a/spec/ruby/library/uri/set_component_spec.rb b/spec/ruby/library/uri/set_component_spec.rb
new file mode 100644
index 0000000000..9b8372108a
--- /dev/null
+++ b/spec/ruby/library/uri/set_component_spec.rb
@@ -0,0 +1,47 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+#TODO: make this more BDD
+describe "URI#select" do
+ it "conforms to the MatzRuby tests" do
+ uri = URI.parse('http://foo:bar@baz')
+ (uri.user = 'oof').should == 'oof'
+ uri.to_s.should == 'http://oof:bar@baz'
+ (uri.password = 'rab').should == 'rab'
+ uri.to_s.should == 'http://oof:rab@baz'
+ (uri.userinfo = 'foo').should == 'foo'
+ uri.to_s.should == 'http://foo:rab@baz'
+ (uri.userinfo = ['foo', 'bar']).should == ['foo', 'bar']
+ uri.to_s.should == 'http://foo:bar@baz'
+ (uri.userinfo = ['foo']).should == ['foo']
+ uri.to_s.should == 'http://foo:bar@baz'
+ (uri.host = 'zab').should == 'zab'
+ uri.to_s.should == 'http://foo:bar@zab'
+ (uri.port = 8080).should == 8080
+ uri.to_s.should == 'http://foo:bar@zab:8080'
+ (uri.path = '/').should == '/'
+ uri.to_s.should == 'http://foo:bar@zab:8080/'
+ (uri.query = 'a=1').should == 'a=1'
+ uri.to_s.should == 'http://foo:bar@zab:8080/?a=1'
+ (uri.fragment = 'b123').should == 'b123'
+ uri.to_s.should == 'http://foo:bar@zab:8080/?a=1#b123'
+
+ uri = URI.parse('http://example.com')
+ lambda { uri.password = 'bar' }.should raise_error(URI::InvalidURIError)
+ uri.userinfo = 'foo:bar'
+ uri.to_s.should == 'http://foo:bar@example.com'
+ lambda { uri.registry = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.opaque = 'bar' }.should raise_error(URI::InvalidURIError)
+
+ uri = URI.parse('mailto:foo@example.com')
+ lambda { uri.user = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.password = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.userinfo = ['bar', 'baz'] }.should raise_error(URI::InvalidURIError)
+ lambda { uri.host = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.port = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.path = 'bar' }.should raise_error(URI::InvalidURIError)
+ lambda { uri.query = 'bar' }.should raise_error(URI::InvalidURIError)
+ end
+end
+
+
diff --git a/spec/ruby/library/uri/shared/eql.rb b/spec/ruby/library/uri/shared/eql.rb
new file mode 100644
index 0000000000..2cc960d39a
--- /dev/null
+++ b/spec/ruby/library/uri/shared/eql.rb
@@ -0,0 +1,17 @@
+describe :uri_eql, shared: true do
+ it "returns false if the normalized forms are different" do
+ URISpec::NORMALIZED_FORMS.each do |form|
+ normal_uri = URI(form[:normalized])
+ form[:different].each do |other|
+ URI(other).send(@method, normal_uri).should be_false
+ end
+ end
+ end
+end
+
+describe :uri_eql_against_other_types, shared: true do
+ it "returns false for when compared to non-uri objects" do
+ URI("http://example.com/").send(@method, "http://example.com/").should be_false
+ URI("http://example.com/").send(@method, nil).should be_false
+ end
+end
diff --git a/spec/ruby/library/uri/shared/extract.rb b/spec/ruby/library/uri/shared/extract.rb
new file mode 100644
index 0000000000..efe60ae4b9
--- /dev/null
+++ b/spec/ruby/library/uri/shared/extract.rb
@@ -0,0 +1,83 @@
+describe :uri_extract, shared: true do
+ it "behaves according to its documentation" do
+ @object.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.").should == ["http://foo.example.org/bla", "mailto:test@example.com"]
+ end
+
+ it "treats contiguous URIs as a single URI" do
+ @object.extract('http://example.jphttp://example.jp').should == ['http://example.jphttp://example.jp']
+ end
+
+ it "treats pretty much anything with a colon as a URI" do
+ @object.extract('From: XXX [mailto:xxx@xxx.xxx.xxx]').should == ['From:', 'mailto:xxx@xxx.xxx.xxx]']
+ end
+
+ it "wraps a URI string in an array" do
+ @object.extract("http://github.com/brixen/rubyspec/tree/master").should == ["http://github.com/brixen/rubyspec/tree/master"]
+ end
+
+ it "pulls a variety of protocol URIs from a string" do
+ @object.extract("this is a string, it has http://rubini.us/ in it").should == ["http://rubini.us/"]
+ @object.extract("mailto:spambait@example.com").should == ["mailto:spambait@example.com"]
+ @object.extract("ftp://ruby-lang.org/").should == ["ftp://ruby-lang.org/"]
+ @object.extract("https://mail.google.com").should == ["https://mail.google.com"]
+ @object.extract("anything://example.com/").should == ["anything://example.com/"]
+ end
+
+ it "pulls all URIs within a string in order into an array when a block is not given" do
+ @object.extract("1.3. Example URI
+
+ The following examples illustrate URI that are in common use.
+
+ ftp://ftp.is.co.za/rfc/rfc1808.txt
+ -- ftp scheme for File Transfer Protocol services
+
+ gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
+ -- gopher scheme for Gopher and Gopher+ Protocol services
+
+ http://www.math.uio.no/faq/compression-faq/part1.html
+ -- http scheme for Hypertext Transfer Protocol services
+
+ mailto:mduerst@ifi.unizh.ch
+ -- mailto scheme for electronic mail addresses
+
+ news:comp.infosystems.www.servers.unix
+ -- news scheme for USENET news groups and articles
+
+ telnet://melvyl.ucop.edu/
+ -- telnet scheme for interactive services via the TELNET Protocol
+ ").should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch","news:comp.infosystems.www.servers.unix","telnet://melvyl.ucop.edu/"]
+ end
+
+ it "yields each URI in the given string in order to a block, if given, and returns nil" do
+ results = ["http://foo.example.org/bla", "mailto:test@example.com"]
+ @object.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.") {|uri|
+ uri.should == results.shift
+ }.should == nil
+ results.should == []
+ end
+
+ it "allows the user to specify a list of acceptable protocols of URIs to scan for" do
+ @object.extract("1.3. Example URI
+
+ The following examples illustrate URI that are in common use.
+
+ ftp://ftp.is.co.za/rfc/rfc1808.txt
+ -- ftp scheme for File Transfer Protocol services
+
+ gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles
+ -- gopher scheme for Gopher and Gopher+ Protocol services
+
+ http://www.math.uio.no/faq/compression-faq/part1.html
+ -- http scheme for Hypertext Transfer Protocol services
+
+ mailto:mduerst@ifi.unizh.ch
+ -- mailto scheme for electronic mail addresses
+
+ news:comp.infosystems.www.servers.unix
+ -- news scheme for USENET news groups and articles
+
+ telnet://melvyl.ucop.edu/
+ -- telnet scheme for interactive services via the TELNET Protocol
+ ", ["http","ftp","mailto"]).should == ["ftp://ftp.is.co.za/rfc/rfc1808.txt","http://www.math.uio.no/faq/compression-faq/part1.html","mailto:mduerst@ifi.unizh.ch"]
+ end
+end
diff --git a/spec/ruby/library/uri/shared/join.rb b/spec/ruby/library/uri/shared/join.rb
new file mode 100644
index 0000000000..dfe44e9be2
--- /dev/null
+++ b/spec/ruby/library/uri/shared/join.rb
@@ -0,0 +1,54 @@
+describe :uri_join, shared: true do
+ it "returns a URI object of the concatenation of a protocol and domain, and a path" do
+ @object.join("http://localhost/","main.rbx").should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "accepts URI objects" do
+ @object.join(URI("http://localhost/"),"main.rbx").should == URI.parse("http://localhost/main.rbx")
+ @object.join("http://localhost/",URI("main.rbx")).should == URI.parse("http://localhost/main.rbx")
+ @object.join(URI("http://localhost/"),URI("main.rbx")).should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "accepts string-like arguments with to_str" do
+ str = mock('string-like')
+ str.should_receive(:to_str).and_return("http://ruby-lang.org")
+ str2 = mock('string-like also')
+ str2.should_receive(:to_str).and_return("foo/bar")
+ @object.join(str, str2).should == URI.parse("http://ruby-lang.org/foo/bar")
+ end
+
+ it "raises an error if given no argument" do
+ lambda{ @object.join }.should raise_error
+ end
+
+ it "doesn't create redundant '/'s" do
+ @object.join("http://localhost/", "/main.rbx").should == URI.parse("http://localhost/main.rbx")
+ end
+
+ it "discards arguments given before an absolute uri" do
+ @object.join("http://localhost/a/b/c/d", "http://ruby-lang.com/foo", "bar").should == URI.parse("http://ruby-lang.com/bar")
+ end
+
+ it "resolves .. in paths" do
+ @object.join("http://localhost/a/b/c/d", "../../e/f", "g/h/../i").to_s.should == "http://localhost/a/e/g/i"
+ end
+end
+
+
+# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo/bar'))
+# assert_equal(URI.parse('http://foo/bar'), URI.join('http://foo', 'bar'))
+# assert_equal(URI.parse('http://foo/bar/'), URI.join('http://foo', 'bar/'))
+#
+# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', 'baz'))
+# assert_equal(URI.parse('http://foo/baz'), URI.join('http://foo', 'bar', '/baz'))
+# assert_equal(URI.parse('http://foo/baz/'), URI.join('http://foo', 'bar', '/baz/'))
+# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/', 'baz'))
+# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar', 'baz', 'hoge'))
+#
+# assert_equal(URI.parse('http://foo/bar/baz'), URI.join('http://foo', 'bar/baz'))
+# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge'))
+# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge'))
+# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge'))
+# assert_equal(URI.parse('http://foo/bar/hoge'), URI.join('http://foo', 'bar/baz', 'hoge'))
+# assert_equal(URI.parse('http://foo/bar/baz/hoge'), URI.join('http://foo', 'bar/baz/', 'hoge'))
+# assert_equal(URI.parse('http://foo/hoge'), URI.join('http://foo', 'bar/baz', '/hoge'))
diff --git a/spec/ruby/library/uri/shared/parse.rb b/spec/ruby/library/uri/shared/parse.rb
new file mode 100644
index 0000000000..5ecbffcaf2
--- /dev/null
+++ b/spec/ruby/library/uri/shared/parse.rb
@@ -0,0 +1,199 @@
+describe :uri_parse, shared: true do
+ it "returns a URI::HTTP object when parsing an HTTP URI" do
+ @object.parse("http://www.example.com/").should be_kind_of(URI::HTTP)
+ end
+
+ it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do
+ # general case
+ URISpec.components(@object.parse("http://user:pass@example.com/path/?query=val&q2=val2#fragment")).should == {
+ scheme: "http",
+ userinfo: "user:pass",
+ host: "example.com",
+ port: 80,
+ path: "/path/",
+ query: "query=val&q2=val2",
+ fragment: "fragment"
+ }
+
+ # multiple paths
+ URISpec.components(@object.parse("http://a/b/c/d;p?q")).should == {
+ scheme: "http",
+ userinfo: nil,
+ host: "a",
+ port: 80,
+ path: "/b/c/d;p",
+ query: "q",
+ fragment: nil
+ }
+
+ # multi-level domain
+ URISpec.components(@object.parse('http://www.math.uio.no/faq/compression-faq/part1.html')).should == {
+ scheme: "http",
+ userinfo: nil,
+ host: "www.math.uio.no",
+ port: 80,
+ path: "/faq/compression-faq/part1.html",
+ query: nil,
+ fragment: nil
+ }
+ end
+
+ it "parses out the port number of a URI, when given" do
+ @object.parse("http://example.com:8080/").port.should == 8080
+ end
+
+ it "returns a URI::HTTPS object when parsing an HTTPS URI" do
+ @object.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS)
+ end
+
+ it "sets the port of a parsed https URI to 443 by default" do
+ @object.parse("https://example.com/").port.should == 443
+ end
+
+ it "populates the components of a parsed URI::FTP object" do
+ # generic, empty password.
+ url = @object.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i")
+ url.should be_kind_of(URI::FTP)
+ URISpec.components(url).should == {
+ scheme: "ftp",
+ userinfo: "anonymous",
+ host: "ruby-lang.org",
+ port: 21,
+ path: "pub/ruby/1.8/ruby-1.8.6.tar.bz2",
+ typecode: "i"
+ }
+
+ # multidomain, no user or password
+ url = @object.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt')
+ url.should be_kind_of(URI::FTP)
+ URISpec.components(url).should == {
+ scheme: "ftp",
+ userinfo: nil,
+ host: "ftp.is.co.za",
+ port: 21,
+ path: "rfc/rfc1808.txt",
+ typecode: nil
+ }
+
+ # empty user
+ url = @object.parse('ftp://:pass@localhost/')
+ url.should be_kind_of(URI::FTP)
+ URISpec.components(url).should == {
+ scheme: "ftp",
+ userinfo: ":pass",
+ host: "localhost",
+ port: 21,
+ path: "",
+ typecode: nil
+ }
+ url.password.should == "pass"
+ end
+
+ it "returns a URI::LDAP object when parsing an LDAP URI" do
+ #taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like
+ ldap_uris = %w{ ldap:///o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress ldap://host.com:6666/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen) ldap://ldap.itd.umich.edu/c=GB?objectClass?one ldap://ldap.question.com/o=Question%3f,c=US?mail ldap://ldap.netscape.com/o=Babsco,c=US??(int=%5c00%5c00%5c00%5c04) ldap:///??sub??bindname=cn=Manager%2co=Foo ldap:///??sub??!bindname=cn=Manager%2co=Foo }
+ ldap_uris.each do |ldap_uri|
+ @object.parse(ldap_uri).should be_kind_of(URI::LDAP)
+ end
+ end
+
+ it "populates the components of a parsed URI::LDAP object" do
+ URISpec.components(@object.parse("ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress?scope?filter?extensions")).should == {
+ scheme: "ldap",
+ host: "ldap.itd.umich.edu",
+ port: 389,
+ dn: "o=University%20of%20Michigan,c=US",
+ attributes: "postalAddress",
+ scope: "scope",
+ filter: "filter",
+ extensions: "extensions"
+ }
+ end
+
+ it "returns a URI::MailTo object when passed a mailto URI" do
+ @object.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo)
+ end
+
+ it "populates the components of a parsed URI::MailTo object" do
+ URISpec.components(@object.parse("mailto:spam@mailinator.com?subject=Discounts%20On%20Imported%20methods!!!&body=Exciting%20offer")).should == {
+ scheme: "mailto",
+ to: "spam@mailinator.com",
+ headers: [["subject","Discounts%20On%20Imported%20methods!!!"],
+ ["body", "Exciting%20offer"]]
+ }
+ end
+
+ # TODO
+ # Test registry
+ it "does its best to extract components from URI::Generic objects" do
+ # generic
+ URISpec.components(URI("scheme://userinfo@host/path?query#fragment")).should == {
+ scheme: "scheme",
+ userinfo: "userinfo",
+ host: "host",
+ port: nil,
+ path: "/path",
+ query: "query",
+ fragment: "fragment",
+ registry: nil,
+ opaque: nil
+ }
+
+ # gopher
+ gopher = @object.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles')
+ gopher.should be_kind_of(URI::Generic)
+
+ URISpec.components(gopher).should == {
+ scheme: "gopher",
+ userinfo: nil,
+ host: "spinaltap.micro.umn.edu",
+ port: nil,
+ path: "/00/Weather/California/Los%20Angeles",
+ query: nil,
+ fragment: nil,
+ registry: nil,
+ opaque: nil
+ }
+
+ # news
+ news = @object.parse('news:comp.infosystems.www.servers.unix')
+ news.should be_kind_of(URI::Generic)
+ URISpec.components(news).should == {
+ scheme: "news",
+ userinfo: nil,
+ host: nil,
+ port: nil,
+ path: nil,
+ query: nil,
+ fragment: nil,
+ registry: nil,
+ opaque: "comp.infosystems.www.servers.unix"
+ }
+
+ # telnet
+ telnet = @object.parse('telnet://melvyl.ucop.edu/')
+ telnet.should be_kind_of(URI::Generic)
+ URISpec.components(telnet).should == {
+ scheme: "telnet",
+ userinfo: nil,
+ host: "melvyl.ucop.edu",
+ port: nil,
+ path: "/",
+ query: nil,
+ fragment: nil,
+ registry: nil,
+ opaque: nil
+ }
+
+ # files
+ file_l = @object.parse('file:///foo/bar.txt')
+ file_l.should be_kind_of(URI::Generic)
+ file = @object.parse('file:/foo/bar.txt')
+ file.should be_kind_of(URI::Generic)
+ end
+
+ it "raises errors on malformed URIs" do
+ lambda { @object.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError)
+ lambda { @object.parse('http://a_b/') }.should raise_error(URI::InvalidURIError)
+ end
+end
diff --git a/spec/ruby/library/uri/split_spec.rb b/spec/ruby/library/uri/split_spec.rb
new file mode 100644
index 0000000000..f0ab6ff35c
--- /dev/null
+++ b/spec/ruby/library/uri/split_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI.split" do
+ it "needs to be reviewed for spec completeness"
+end
diff --git a/spec/ruby/library/uri/uri_spec.rb b/spec/ruby/library/uri/uri_spec.rb
new file mode 100644
index 0000000000..90936a770f
--- /dev/null
+++ b/spec/ruby/library/uri/uri_spec.rb
@@ -0,0 +1,29 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'uri'
+
+#the testing is light here as this is an alias for URI.parse
+
+#we're just testing that the method ends up in the right place
+describe "the URI method" do
+ it "parses a given URI, returning a URI object" do
+ result = URI.parse("http://ruby-lang.org")
+ URI("http://ruby-lang.org").should == result
+ Kernel::URI("http://ruby-lang.org").should == result
+ end
+
+ it "converts its argument with to_str" do
+ str = mock('string-like')
+ str.should_receive(:to_str).and_return("http://ruby-lang.org")
+ URI(str).should == URI.parse("http://ruby-lang.org")
+ end
+
+ it "returns the argument if it is a URI object" do
+ result = URI.parse("http://ruby-lang.org")
+ URI(result).should equal(result)
+ end
+
+ #apparently this was a concern? imported from MRI tests
+ it "does not add a URI method to Object instances" do
+ lambda {Object.new.URI("http://ruby-lang.org/")}.should raise_error(NoMethodError)
+ end
+end
diff --git a/spec/ruby/library/uri/util/make_components_hash_spec.rb b/spec/ruby/library/uri/util/make_components_hash_spec.rb
new file mode 100644
index 0000000000..0f491112e8
--- /dev/null
+++ b/spec/ruby/library/uri/util/make_components_hash_spec.rb
@@ -0,0 +1,6 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'uri'
+
+describe "URI::Util.make_components_hash" do
+ it "needs to be reviewed for spec completeness"
+end