rubysl-uri 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.travis.yml +7 -0
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/lib/rubysl/uri.rb +2 -0
- data/lib/rubysl/uri/uri.rb +29 -0
- data/lib/rubysl/uri/version.rb +5 -0
- data/lib/uri.rb +1 -0
- data/lib/uri/common.rb +613 -0
- data/lib/uri/ftp.rb +198 -0
- data/lib/uri/generic.rb +1126 -0
- data/lib/uri/http.rb +100 -0
- data/lib/uri/https.rb +20 -0
- data/lib/uri/ldap.rb +190 -0
- data/lib/uri/ldaps.rb +12 -0
- data/lib/uri/mailto.rb +266 -0
- data/rubysl-uri.gemspec +18 -18
- data/spec/decode_www_form_component_spec.rb +7 -0
- data/spec/decode_www_form_spec.rb +7 -0
- data/spec/encode_www_form_component_spec.rb +7 -0
- data/spec/encode_www_form_spec.rb +7 -0
- data/spec/eql_spec.rb +11 -0
- data/spec/equality_spec.rb +47 -0
- data/spec/escape/decode_spec.rb +5 -0
- data/spec/escape/encode_spec.rb +5 -0
- data/spec/escape/escape_spec.rb +5 -0
- data/spec/escape/unescape_spec.rb +5 -0
- data/spec/extract_spec.rb +85 -0
- data/spec/fixtures/classes.rb +11 -0
- data/spec/fixtures/normalization.rb +54 -0
- data/spec/ftp/build_spec.rb +5 -0
- data/spec/ftp/merge_spec.rb +5 -0
- data/spec/ftp/new2_spec.rb +5 -0
- data/spec/ftp/path_spec.rb +55 -0
- data/spec/ftp/set_typecode_spec.rb +5 -0
- data/spec/ftp/to_s_spec.rb +24 -0
- data/spec/ftp/typecode_spec.rb +9 -0
- data/spec/generic/absolute_spec.rb +9 -0
- data/spec/generic/build2_spec.rb +5 -0
- data/spec/generic/build_spec.rb +5 -0
- data/spec/generic/coerce_spec.rb +5 -0
- data/spec/generic/component_ary_spec.rb +5 -0
- data/spec/generic/component_spec.rb +9 -0
- data/spec/generic/default_port_spec.rb +9 -0
- data/spec/generic/eql_spec.rb +5 -0
- data/spec/generic/equal_value_spec.rb +5 -0
- data/spec/generic/fragment_spec.rb +9 -0
- data/spec/generic/hash_spec.rb +5 -0
- data/spec/generic/hierarchical_spec.rb +5 -0
- data/spec/generic/host_spec.rb +9 -0
- data/spec/generic/inspect_spec.rb +5 -0
- data/spec/generic/merge_spec.rb +9 -0
- data/spec/generic/minus_spec.rb +5 -0
- data/spec/generic/normalize_spec.rb +9 -0
- data/spec/generic/opaque_spec.rb +9 -0
- data/spec/generic/password_spec.rb +9 -0
- data/spec/generic/path_spec.rb +9 -0
- data/spec/generic/plus_spec.rb +5 -0
- data/spec/generic/port_spec.rb +9 -0
- data/spec/generic/query_spec.rb +9 -0
- data/spec/generic/registry_spec.rb +9 -0
- data/spec/generic/relative_spec.rb +5 -0
- data/spec/generic/route_from_spec.rb +5 -0
- data/spec/generic/route_to_spec.rb +5 -0
- data/spec/generic/scheme_spec.rb +9 -0
- data/spec/generic/select_spec.rb +5 -0
- data/spec/generic/set_fragment_spec.rb +5 -0
- data/spec/generic/set_host_spec.rb +5 -0
- data/spec/generic/set_opaque_spec.rb +5 -0
- data/spec/generic/set_password_spec.rb +5 -0
- data/spec/generic/set_path_spec.rb +5 -0
- data/spec/generic/set_port_spec.rb +5 -0
- data/spec/generic/set_query_spec.rb +5 -0
- data/spec/generic/set_registry_spec.rb +5 -0
- data/spec/generic/set_scheme_spec.rb +5 -0
- data/spec/generic/set_user_spec.rb +5 -0
- data/spec/generic/set_userinfo_spec.rb +5 -0
- data/spec/generic/to_s_spec.rb +5 -0
- data/spec/generic/use_registry_spec.rb +5 -0
- data/spec/generic/user_spec.rb +9 -0
- data/spec/generic/userinfo_spec.rb +9 -0
- data/spec/http/build_spec.rb +5 -0
- data/spec/http/request_uri_spec.rb +15 -0
- data/spec/join_spec.rb +60 -0
- data/spec/ldap/attributes_spec.rb +9 -0
- data/spec/ldap/build_spec.rb +5 -0
- data/spec/ldap/dn_spec.rb +9 -0
- data/spec/ldap/extensions_spec.rb +9 -0
- data/spec/ldap/filter_spec.rb +9 -0
- data/spec/ldap/hierarchical_spec.rb +5 -0
- data/spec/ldap/scope_spec.rb +9 -0
- data/spec/ldap/set_attributes_spec.rb +5 -0
- data/spec/ldap/set_dn_spec.rb +5 -0
- data/spec/ldap/set_extensions_spec.rb +5 -0
- data/spec/ldap/set_filter_spec.rb +5 -0
- data/spec/ldap/set_scope_spec.rb +5 -0
- data/spec/mailto/build_spec.rb +98 -0
- data/spec/mailto/headers_spec.rb +9 -0
- data/spec/mailto/set_headers_spec.rb +5 -0
- data/spec/mailto/set_to_spec.rb +5 -0
- data/spec/mailto/to_mailtext_spec.rb +5 -0
- data/spec/mailto/to_rfc822text_spec.rb +5 -0
- data/spec/mailto/to_s_spec.rb +5 -0
- data/spec/mailto/to_spec.rb +9 -0
- data/spec/merge_spec.rb +21 -0
- data/spec/normalize_spec.rb +34 -0
- data/spec/parse_spec.rb +248 -0
- data/spec/parser/escape_spec.rb +7 -0
- data/spec/parser/extract_spec.rb +8 -0
- data/spec/parser/inspect_spec.rb +7 -0
- data/spec/parser/join_spec.rb +8 -0
- data/spec/parser/make_regexp_spec.rb +7 -0
- data/spec/parser/parse_spec.rb +8 -0
- data/spec/parser/split_spec.rb +7 -0
- data/spec/parser/unescape_spec.rb +7 -0
- data/spec/plus_spec.rb +488 -0
- data/spec/regexp_spec.rb +17 -0
- data/spec/route_from_spec.rb +24 -0
- data/spec/route_to_spec.rb +27 -0
- data/spec/select_spec.rb +30 -0
- data/spec/set_component_spec.rb +46 -0
- data/spec/shared/eql.rb +17 -0
- data/spec/shared/extract.rb +83 -0
- data/spec/shared/join.rb +58 -0
- data/spec/shared/parse.rb +245 -0
- data/spec/split_spec.rb +5 -0
- data/spec/uri_spec.rb +30 -0
- data/spec/util/make_components_hash_spec.rb +5 -0
- metadata +297 -88
- data/lib/rubysl-uri.rb +0 -7
- data/lib/rubysl-uri/version.rb +0 -5
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
describe "URI::Mailto.build" do
|
4
|
+
it "conforms to the MatzRuby tests" do
|
5
|
+
ok = []
|
6
|
+
bad = []
|
7
|
+
|
8
|
+
# RFC2368, 6. Examples
|
9
|
+
# mailto:chris@example.com
|
10
|
+
ok << ["mailto:chris@example.com"]
|
11
|
+
ok[-1] << ["chris@example.com", nil]
|
12
|
+
ok[-1] << {:to => "chris@example.com"}
|
13
|
+
|
14
|
+
# mailto:infobot@example.com?subject=current-issue
|
15
|
+
ok << ["mailto:infobot@example.com?subject=current-issue"]
|
16
|
+
ok[-1] << ["infobot@example.com", ["subject=current-issue"]]
|
17
|
+
ok[-1] << {:to => "infobot@example.com",
|
18
|
+
:headers => ["subject=current-issue"]}
|
19
|
+
|
20
|
+
# mailto:infobot@example.com?body=send%20current-issue
|
21
|
+
ok << ["mailto:infobot@example.com?body=send%20current-issue"]
|
22
|
+
ok[-1] << ["infobot@example.com", ["body=send%20current-issue"]]
|
23
|
+
ok[-1] << {:to => "infobot@example.com",
|
24
|
+
:headers => ["body=send%20current-issue"]}
|
25
|
+
|
26
|
+
# mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index
|
27
|
+
ok << ["mailto:infobot@example.com?body=send%20current-issue%0D%0Asend%20index"]
|
28
|
+
ok[-1] << ["infobot@example.com",
|
29
|
+
["body=send%20current-issue%0D%0Asend%20index"]]
|
30
|
+
ok[-1] << {:to => "infobot@example.com",
|
31
|
+
:headers => ["body=send%20current-issue%0D%0Asend%20index"]}
|
32
|
+
|
33
|
+
# mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com
|
34
|
+
ok << ["mailto:foobar@example.com?In-Reply-To=%3c3469A91.D10AF4C@example.com"]
|
35
|
+
ok[-1] << ["foobar@example.com",
|
36
|
+
["In-Reply-To=%3c3469A91.D10AF4C@example.com"]]
|
37
|
+
ok[-1] << {:to => "foobar@example.com",
|
38
|
+
:headers => ["In-Reply-To=%3c3469A91.D10AF4C@example.com"]}
|
39
|
+
|
40
|
+
# mailto:majordomo@example.com?body=subscribe%20bamboo-l
|
41
|
+
ok << ["mailto:majordomo@example.com?body=subscribe%20bamboo-l"]
|
42
|
+
ok[-1] << ["majordomo@example.com", ["body=subscribe%20bamboo-l"]]
|
43
|
+
ok[-1] << {:to => "majordomo@example.com",
|
44
|
+
:headers => ["body=subscribe%20bamboo-l"]}
|
45
|
+
|
46
|
+
# mailto:joe@example.com?cc=bob@example.com&body=hello
|
47
|
+
ok << ["mailto:joe@example.com?cc=bob@example.com&body=hello"]
|
48
|
+
ok[-1] << ["joe@example.com", ["cc=bob@example.com", "body=hello"]]
|
49
|
+
ok[-1] << {:to => "joe@example.com",
|
50
|
+
:headers => ["cc=bob@example.com", "body=hello"]}
|
51
|
+
|
52
|
+
# mailto:?to=joe@example.com&cc=bob@example.com&body=hello
|
53
|
+
ok << ["mailto:?to=joe@example.com&cc=bob@example.com&body=hello"]
|
54
|
+
ok[-1] << [nil,
|
55
|
+
["to=joe@example.com", "cc=bob@example.com", "body=hello"]]
|
56
|
+
ok[-1] << {:headers => ["to=joe@example.com",
|
57
|
+
"cc=bob@example.com", "body=hello"]}
|
58
|
+
|
59
|
+
# mailto:gorby%25kremvax@example.com
|
60
|
+
ok << ["mailto:gorby%25kremvax@example.com"]
|
61
|
+
ok[-1] << ["gorby%25kremvax@example.com", nil]
|
62
|
+
ok[-1] << {:to => "gorby%25kremvax@example.com"}
|
63
|
+
|
64
|
+
# mailto:unlikely%3Faddress@example.com?blat=foop
|
65
|
+
ok << ["mailto:unlikely%3Faddress@example.com?blat=foop"]
|
66
|
+
ok[-1] << ["unlikely%3Faddress@example.com", ["blat=foop"]]
|
67
|
+
ok[-1] << {:to => "unlikely%3Faddress@example.com",
|
68
|
+
:headers => ["blat=foop"]}
|
69
|
+
|
70
|
+
ok_all = ok.flatten.join("\0")
|
71
|
+
|
72
|
+
# mailto:joe@example.com?cc=bob@example.com?body=hello ; WRONG!
|
73
|
+
bad << ["joe@example.com", ["cc=bob@example.com?body=hello"]]
|
74
|
+
|
75
|
+
# mailto:javascript:alert()
|
76
|
+
bad << ["javascript:alert()", []]
|
77
|
+
|
78
|
+
# '=' which is in hname or hvalue is wrong.
|
79
|
+
bad << ["foo@example.jp?subject=1+1=2", []]
|
80
|
+
|
81
|
+
ok.each do |x|
|
82
|
+
URI::MailTo.build(x[1]).to_s.should == x[0]
|
83
|
+
URI::MailTo.build(x[2]).to_s.should == x[0]
|
84
|
+
end
|
85
|
+
|
86
|
+
bad.each do |x|
|
87
|
+
lambda { URI::MailTo.build(x) }.should raise_error(URI::InvalidComponentError)
|
88
|
+
end
|
89
|
+
|
90
|
+
ok.flatten.join("\0").should == ok_all
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
describe "URI::MailTo.build" do
|
97
|
+
it "needs to be reviewed for spec completeness"
|
98
|
+
end
|
data/spec/merge_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
describe "URI#merge" do
|
4
|
+
it "returns the receiver and the argument, joined as per URI.join" do
|
5
|
+
URI("http://localhost/").merge("main.rbx").should == URI.parse("http://localhost/main.rbx")
|
6
|
+
URI("http://localhost/a/b/c/d").merge("http://ruby-lang.com/foo").should == URI.parse("http://ruby-lang.com/foo")
|
7
|
+
URI("http://localhost/a/b/c/d").merge("../../e/f").to_s.should == "http://localhost/a/e/f"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "accepts URI objects as argument" do
|
11
|
+
URI("http://localhost/").merge(URI("main.rbx")).should == URI.parse("http://localhost/main.rbx")
|
12
|
+
end
|
13
|
+
|
14
|
+
ruby_bug "redmine:3506", "1.9.2" do
|
15
|
+
it "accepts a string-like argument" do
|
16
|
+
str = mock('string-like')
|
17
|
+
str.should_receive(:to_str).and_return("foo/bar")
|
18
|
+
URI("http://localhost/").merge(str).should == URI.parse("http://localhost/foo/bar")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path('../fixtures/normalization', __FILE__)
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
describe "URI#normalize" do
|
5
|
+
it "adds a / onto the end of the URI if the path is blank" do
|
6
|
+
no_path = URI("http://example.com")
|
7
|
+
no_path.to_s.should_not == "http://example.com/"
|
8
|
+
no_path.normalize.to_s.should == "http://example.com/"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "downcases the host of the URI" do
|
12
|
+
uri = URI("http://exAMPLE.cOm/")
|
13
|
+
uri.to_s.should_not == "http://example.com/"
|
14
|
+
uri.normalize.to_s.should == "http://example.com/"
|
15
|
+
end
|
16
|
+
|
17
|
+
# The previous tests are included by the one below
|
18
|
+
|
19
|
+
quarantine! do # Quarantined until redmine:2542 is accepted
|
20
|
+
it "respects RFC 3986" do
|
21
|
+
URISpec::NORMALIZED_FORMS.each do |form|
|
22
|
+
normal_uri = URI(form[:normalized])
|
23
|
+
normalized = normal_uri.normalize.to_s
|
24
|
+
normal_uri.to_s.should == normalized
|
25
|
+
form[:equivalent].each do |same|
|
26
|
+
URI(same).normalize.to_s.should == normalized
|
27
|
+
end
|
28
|
+
form[:different].each do |other|
|
29
|
+
URI(other).normalize.to_s.should_not == normalized
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/parse_spec.rb
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
require File.expand_path('../fixtures/classes', __FILE__)
|
2
|
+
|
3
|
+
describe "URI.parse" do
|
4
|
+
|
5
|
+
it "returns a URI::HTTP object when parsing an HTTP URI" do
|
6
|
+
URI.parse("http://www.example.com/").should be_kind_of(URI::HTTP)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "populates the components of a parsed URI::HTTP, setting the port to 80 by default" do
|
10
|
+
# general case
|
11
|
+
URISpec.components(URI.parse("http://user:pass@example.com/path/?query=val&q2=val2#fragment")).should == {
|
12
|
+
:scheme => "http",
|
13
|
+
:userinfo => "user:pass",
|
14
|
+
:host => "example.com",
|
15
|
+
:port => 80,
|
16
|
+
:path => "/path/",
|
17
|
+
:query => "query=val&q2=val2",
|
18
|
+
:fragment => "fragment"
|
19
|
+
}
|
20
|
+
|
21
|
+
# multiple paths
|
22
|
+
URISpec.components(URI.parse("http://a/b/c/d;p?q")).should == {
|
23
|
+
:scheme => "http",
|
24
|
+
:userinfo => nil,
|
25
|
+
:host => "a",
|
26
|
+
:port => 80,
|
27
|
+
:path => "/b/c/d;p",
|
28
|
+
:query => "q",
|
29
|
+
:fragment => nil
|
30
|
+
}
|
31
|
+
|
32
|
+
# multi-level domain
|
33
|
+
URISpec.components(URI.parse('http://www.math.uio.no/faq/compression-faq/part1.html')).should == {
|
34
|
+
:scheme => "http",
|
35
|
+
:userinfo => nil,
|
36
|
+
:host => "www.math.uio.no",
|
37
|
+
:port => 80,
|
38
|
+
:path => "/faq/compression-faq/part1.html",
|
39
|
+
:query => nil,
|
40
|
+
:fragment => nil
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "parses out the port number of a URI, when given" do
|
45
|
+
URI.parse("http://example.com:8080/").port.should == 8080
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns a URI::HTTPS object when parsing an HTTPS URI" do
|
49
|
+
URI.parse("https://important-intern-net.net").should be_kind_of(URI::HTTPS)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "sets the port of a parsed https URI to 443 by default" do
|
53
|
+
URI.parse("https://example.com/").port.should == 443
|
54
|
+
end
|
55
|
+
|
56
|
+
ruby_version_is "".."1.8.6" do
|
57
|
+
it "populates the components of a parsed URI::FTP object" do
|
58
|
+
# generic, empty password.
|
59
|
+
url = URI.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i")
|
60
|
+
url.should be_kind_of(URI::FTP)
|
61
|
+
URISpec.components(url).should == {
|
62
|
+
:scheme => "ftp",
|
63
|
+
:userinfo => "anonymous",
|
64
|
+
:host => "ruby-lang.org",
|
65
|
+
:port => 21,
|
66
|
+
:path => "pub/ruby/1.8/ruby-1.8.6.tar.bz2",
|
67
|
+
:typecode => "i"
|
68
|
+
}
|
69
|
+
|
70
|
+
# multidomain, no user or password
|
71
|
+
url = URI.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt')
|
72
|
+
url.should be_kind_of(URI::FTP)
|
73
|
+
URISpec.components(url).should == {
|
74
|
+
:scheme => "ftp",
|
75
|
+
:userinfo => nil,
|
76
|
+
:host => "ftp.is.co.za",
|
77
|
+
:port => 21,
|
78
|
+
:path => "rfc/rfc1808.txt",
|
79
|
+
:typecode => nil
|
80
|
+
}
|
81
|
+
|
82
|
+
# empty user
|
83
|
+
url = URI.parse('ftp://:pass@localhost/')
|
84
|
+
url.should be_kind_of(URI::FTP)
|
85
|
+
URISpec.components(url).should == {
|
86
|
+
:scheme => "ftp",
|
87
|
+
:userinfo => ":pass",
|
88
|
+
:host => "localhost",
|
89
|
+
:port => 21,
|
90
|
+
:path => "/",
|
91
|
+
:typecode => nil
|
92
|
+
}
|
93
|
+
url.password.should == "pass"
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
ruby_version_is "1.8.7".."" do
|
99
|
+
it "populates the components of a parsed URI::FTP object" do
|
100
|
+
# generic, empty password.
|
101
|
+
url = URI.parse("ftp://anonymous@ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.bz2;type=i")
|
102
|
+
url.should be_kind_of(URI::FTP)
|
103
|
+
URISpec.components(url).should == {
|
104
|
+
:scheme => "ftp",
|
105
|
+
:userinfo => "anonymous",
|
106
|
+
:host => "ruby-lang.org",
|
107
|
+
:port => 21,
|
108
|
+
:path => "/pub/ruby/1.8/ruby-1.8.6.tar.bz2",
|
109
|
+
:typecode => "i"
|
110
|
+
}
|
111
|
+
|
112
|
+
# multidomain, no user or password
|
113
|
+
url = URI.parse('ftp://ftp.is.co.za/rfc/rfc1808.txt')
|
114
|
+
url.should be_kind_of(URI::FTP)
|
115
|
+
URISpec.components(url).should == {
|
116
|
+
:scheme => "ftp",
|
117
|
+
:userinfo => nil,
|
118
|
+
:host => "ftp.is.co.za",
|
119
|
+
:port => 21,
|
120
|
+
:path => "/rfc/rfc1808.txt",
|
121
|
+
:typecode => nil
|
122
|
+
}
|
123
|
+
|
124
|
+
# empty user
|
125
|
+
url = URI.parse('ftp://:pass@localhost/')
|
126
|
+
url.should be_kind_of(URI::FTP)
|
127
|
+
URISpec.components(url).should == {
|
128
|
+
:scheme => "ftp",
|
129
|
+
:userinfo => ":pass",
|
130
|
+
:host => "localhost",
|
131
|
+
:port => 21,
|
132
|
+
:path => "/",
|
133
|
+
:typecode => nil
|
134
|
+
}
|
135
|
+
url.password.should == "pass"
|
136
|
+
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
it "returns a URI::LDAP object when parsing an LDAP URI" do
|
142
|
+
#taken from http://www.faqs.org/rfcs/rfc2255.html 'cause I don't really know what an LDAP url looks like
|
143
|
+
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 }
|
144
|
+
ldap_uris.each do |ldap_uri|
|
145
|
+
URI.parse(ldap_uri).should be_kind_of(URI::LDAP)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
it "populates the components of a parsed URI::LDAP object" do
|
150
|
+
URISpec.components(URI.parse("ldap://ldap.itd.umich.edu/o=University%20of%20Michigan,c=US?postalAddress?scope?filter?extensions")).should == {
|
151
|
+
:scheme => "ldap",
|
152
|
+
:host => "ldap.itd.umich.edu",
|
153
|
+
:port => 389,
|
154
|
+
:dn => "o=University%20of%20Michigan,c=US",
|
155
|
+
:attributes => "postalAddress",
|
156
|
+
:scope => "scope",
|
157
|
+
:filter => "filter",
|
158
|
+
:extensions => "extensions"
|
159
|
+
}
|
160
|
+
end
|
161
|
+
|
162
|
+
it "returns a URI::MailTo object when passed a mailto URI" do
|
163
|
+
URI.parse("mailto:spam@mailinator.com").should be_kind_of(URI::MailTo)
|
164
|
+
end
|
165
|
+
|
166
|
+
it "populates the components of a parsed URI::MailTo object" do
|
167
|
+
URISpec.components(URI.parse("mailto:spam@mailinator.com?subject=Discounts%20On%20Imported%20methods!!!&body=Exciting%20offer")).should == {
|
168
|
+
:scheme => "mailto",
|
169
|
+
:to => "spam@mailinator.com",
|
170
|
+
:headers => [["subject","Discounts%20On%20Imported%20methods!!!"],
|
171
|
+
["body", "Exciting%20offer"]]
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
175
|
+
# TODO
|
176
|
+
# Test registry
|
177
|
+
it "does its best to extract components from URI::Generic objects" do
|
178
|
+
# generic
|
179
|
+
URISpec.components(URI("scheme://userinfo@host/path?query#fragment")).should == {
|
180
|
+
:scheme => "scheme",
|
181
|
+
:userinfo => "userinfo",
|
182
|
+
:host => "host",
|
183
|
+
:port => nil,
|
184
|
+
:path => "/path",
|
185
|
+
:query => "query",
|
186
|
+
:fragment => "fragment",
|
187
|
+
:registry => nil,
|
188
|
+
:opaque => nil
|
189
|
+
}
|
190
|
+
|
191
|
+
# gopher
|
192
|
+
gopher = URI.parse('gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles')
|
193
|
+
gopher.should be_kind_of(URI::Generic)
|
194
|
+
|
195
|
+
URISpec.components(gopher).should == {
|
196
|
+
:scheme => "gopher",
|
197
|
+
:userinfo => nil,
|
198
|
+
:host => "spinaltap.micro.umn.edu",
|
199
|
+
:port => nil,
|
200
|
+
:path => "/00/Weather/California/Los%20Angeles",
|
201
|
+
:query => nil,
|
202
|
+
:fragment => nil,
|
203
|
+
:registry => nil,
|
204
|
+
:opaque => nil
|
205
|
+
}
|
206
|
+
|
207
|
+
# news
|
208
|
+
news = URI.parse('news:comp.infosystems.www.servers.unix')
|
209
|
+
news.should be_kind_of(URI::Generic)
|
210
|
+
URISpec.components(news).should == {
|
211
|
+
:scheme => "news",
|
212
|
+
:userinfo => nil,
|
213
|
+
:host => nil,
|
214
|
+
:port => nil,
|
215
|
+
:path => nil,
|
216
|
+
:query => nil,
|
217
|
+
:fragment => nil,
|
218
|
+
:registry => nil,
|
219
|
+
:opaque => "comp.infosystems.www.servers.unix"
|
220
|
+
}
|
221
|
+
|
222
|
+
# telnet
|
223
|
+
telnet = URI.parse('telnet://melvyl.ucop.edu/')
|
224
|
+
telnet.should be_kind_of(URI::Generic)
|
225
|
+
URISpec.components(telnet).should == {
|
226
|
+
:scheme => "telnet",
|
227
|
+
:userinfo => nil,
|
228
|
+
:host => "melvyl.ucop.edu",
|
229
|
+
:port => nil,
|
230
|
+
:path => "/",
|
231
|
+
:query => nil,
|
232
|
+
:fragment => nil,
|
233
|
+
:registry => nil,
|
234
|
+
:opaque => nil
|
235
|
+
}
|
236
|
+
|
237
|
+
# files
|
238
|
+
file_l = URI.parse('file:///foo/bar.txt')
|
239
|
+
file_l.should be_kind_of(URI::Generic)
|
240
|
+
file = URI.parse('file:/foo/bar.txt')
|
241
|
+
file.should be_kind_of(URI::Generic)
|
242
|
+
end
|
243
|
+
|
244
|
+
it "raises errors on malformed URIs" do
|
245
|
+
lambda { URI.parse('http://a_b:80/') }.should raise_error(URI::InvalidURIError)
|
246
|
+
lambda { URI.parse('http://a_b/') }.should raise_error(URI::InvalidURIError)
|
247
|
+
end
|
248
|
+
end
|