Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/uri/test_ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ def test_paths
# If you think what's below is wrong, please read RubyForge bug 2055,
# RFC 1738 section 3.2.2, and RFC 2396.
u = URI.parse('ftp://ftp.example.com/foo/bar/file.ext')
assert(u.path == 'foo/bar/file.ext')
assert_equal('foo/bar/file.ext', u.path)
u = URI.parse('ftp://ftp.example.com//foo/bar/file.ext')
assert(u.path == '/foo/bar/file.ext')
assert_equal('/foo/bar/file.ext', u.path)
u = URI.parse('ftp://ftp.example.com/%2Ffoo/bar/file.ext')
assert(u.path == '/foo/bar/file.ext')
assert_equal('/foo/bar/file.ext', u.path)
end

def test_assemble
# uri/ftp is conservative and uses the older RFC 1738 rules, rather than
# assuming everyone else has implemented RFC 2396.
uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
'/path/file.zip', 'i'])
assert(uri.to_s ==
'ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i')
assert_equal('ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i',
uri.to_s)
end

def test_select
Expand Down
40 changes: 20 additions & 20 deletions test/uri/test_generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def test_merge
u = URI.parse('http://foo/bar/baz')
assert_equal(nil, u.merge!(""))
assert_equal(nil, u.merge!(u))
assert(nil != u.merge!("."))
refute_nil(u.merge!("."))
assert_equal('http://foo/bar/', u.to_s)
assert(nil != u.merge!("../baz"))
refute_nil(u.merge!("../baz"))
assert_equal('http://foo/baz', u.to_s)

url = URI.parse('http://a/b//c') + 'd//e'
Expand Down Expand Up @@ -356,7 +356,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/g', url.to_s)
url = @base_url.route_to('http://a/b/c/g')
assert_kind_of(URI::Generic, url)
assert('./g' != url.to_s) # ok
refute_equal('./g', url.to_s) # ok
assert_equal('g', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -375,7 +375,7 @@ def test_rfc3986_examples
assert_equal('http://a/g', url.to_s)
url = @base_url.route_to('http://a/g')
assert_kind_of(URI::Generic, url)
assert('/g' != url.to_s) # ok
refute_equal('/g', url.to_s) # ok
assert_equal('../../g', url.to_s)

# http://a/b/c/d;p?q
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/', url.to_s)
url = @base_url.route_to('http://a/b/c/')
assert_kind_of(URI::Generic, url)
assert('.' != url.to_s) # ok
refute_equal('.', url.to_s) # ok
assert_equal('./', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -485,7 +485,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/', url.to_s)
url = @base_url.route_to('http://a/b/')
assert_kind_of(URI::Generic, url)
assert('..' != url.to_s) # ok
refute_equal('..', url.to_s) # ok
assert_equal('../', url.to_s)

# http://a/b/c/d;p?q
Expand Down Expand Up @@ -513,7 +513,7 @@ def test_rfc3986_examples
assert_equal('http://a/', url.to_s)
url = @base_url.route_to('http://a/')
assert_kind_of(URI::Generic, url)
assert('../..' != url.to_s) # ok
refute_equal('../..', url.to_s) # ok
assert_equal('../../', url.to_s)

# http://a/b/c/d;p?q
Expand Down Expand Up @@ -604,7 +604,7 @@ def test_rfc3986_examples
assert_equal('http://a/g', url.to_s)
url = @base_url.route_to('http://a/g')
assert_kind_of(URI::Generic, url)
assert('../../../g' != url.to_s) # ok? yes, it confuses you
refute_equal('../../../g', url.to_s) # ok? yes, it confuses you
assert_equal('../../g', url.to_s) # and it is clearly

# http://a/b/c/d;p?q
Expand All @@ -614,7 +614,7 @@ def test_rfc3986_examples
assert_equal('http://a/g', url.to_s)
url = @base_url.route_to('http://a/g')
assert_kind_of(URI::Generic, url)
assert('../../../../g' != url.to_s) # ok? yes, it confuses you
refute_equal('../../../../g', url.to_s) # ok? yes, it confuses you
assert_equal('../../g', url.to_s) # and it is clearly

# http://a/b/c/d;p?q
Expand All @@ -624,7 +624,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/g', url.to_s)
url = @base_url.route_to('http://a/b/g')
assert_kind_of(URI::Generic, url)
assert('./../g' != url.to_s) # ok
refute_equal('./../g', url.to_s) # ok
assert_equal('../g', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -634,7 +634,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/g/', url.to_s)
url = @base_url.route_to('http://a/b/c/g/')
assert_kind_of(URI::Generic, url)
assert('./g/.' != url.to_s) # ok
refute_equal('./g/.', url.to_s) # ok
assert_equal('g/', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -644,7 +644,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/g/h', url.to_s)
url = @base_url.route_to('http://a/b/c/g/h')
assert_kind_of(URI::Generic, url)
assert('g/./h' != url.to_s) # ok
refute_equal('g/./h', url.to_s) # ok
assert_equal('g/h', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -654,7 +654,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/h', url.to_s)
url = @base_url.route_to('http://a/b/c/h')
assert_kind_of(URI::Generic, url)
assert('g/../h' != url.to_s) # ok
refute_equal('g/../h', url.to_s) # ok
assert_equal('h', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -664,7 +664,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/g;x=1/y', url.to_s)
url = @base_url.route_to('http://a/b/c/g;x=1/y')
assert_kind_of(URI::Generic, url)
assert('g;x=1/./y' != url.to_s) # ok
refute_equal('g;x=1/./y', url.to_s) # ok
assert_equal('g;x=1/y', url.to_s)

# http://a/b/c/d;p?q
Expand All @@ -674,7 +674,7 @@ def test_rfc3986_examples
assert_equal('http://a/b/c/y', url.to_s)
url = @base_url.route_to('http://a/b/c/y')
assert_kind_of(URI::Generic, url)
assert('g;x=1/../y' != url.to_s) # ok
refute_equal('g;x=1/../y', url.to_s) # ok
assert_equal('y', url.to_s)

# http://a/b/c/d;p?q
Expand Down Expand Up @@ -822,18 +822,18 @@ def test_hierarchical
hierarchical = URI.parse('http://a.b.c/example')
opaque = URI.parse('mailto:mduerst@ifi.unizh.ch')

assert hierarchical.hierarchical?
refute opaque.hierarchical?
assert_predicate hierarchical, :hierarchical?
refute_predicate opaque, :hierarchical?
end

def test_absolute
abs_uri = URI.parse('http://a.b.c/')
not_abs = URI.parse('a.b.c')

refute not_abs.absolute?
refute_predicate not_abs, :absolute?

assert abs_uri.absolute
assert abs_uri.absolute?
assert_predicate abs_uri, :absolute
assert_predicate abs_uri, :absolute?
end

def test_ipv6
Expand Down
16 changes: 8 additions & 8 deletions test/uri/test_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ def test_normalize
host = 'aBcD'
u1 = URI.parse('http://' + host + '/eFg?HiJ')
u2 = URI.parse('http://' + host.downcase + '/eFg?HiJ')
assert(u1.normalize.host == 'abcd')
assert(u1.normalize.path == u1.path)
assert(u1.normalize == u2.normalize)
assert(!u1.normalize.host.equal?(u1.host))
assert( u2.normalize.host.equal?(u2.host))
assert_equal('abcd', u1.normalize.host)
assert_equal(u1.path, u1.normalize.path)
assert_equal(u2.normalize, u1.normalize)
refute_same(u1.host, u1.normalize.host)
assert_same(u2.host, u2.normalize.host)

assert_equal('http://abc/', URI.parse('http://abc').normalize.to_s)
end

def test_equal
assert(URI.parse('http://abc') == URI.parse('http://ABC'))
assert(URI.parse('http://abc/def') == URI.parse('http://ABC/def'))
assert(URI.parse('http://abc/def') != URI.parse('http://ABC/DEF'))
assert_equal(URI.parse('http://ABC'), URI.parse('http://abc'))
assert_equal(URI.parse('http://ABC/def'), URI.parse('http://abc/def'))
refute_equal(URI.parse('http://ABC/DEF'), URI.parse('http://abc/def'))
end

def test_request_uri
Expand Down
18 changes: 9 additions & 9 deletions test/uri/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ def test_compare
u2 = p.parse(url)
u3 = p.parse(url)

assert(u0 == u1)
assert(u0.eql?(u1))
assert(!u0.equal?(u1))
assert_equal(u1, u0)
assert_send([u0, :eql?, u1])
refute_same(u1, u0)

assert(u1 == u2)
assert(!u1.eql?(u2))
assert(!u1.equal?(u2))
assert_equal(u2, u1)
assert_not_send([u1, :eql?, u2])
refute_same(u1, u2)

assert(u2 == u3)
assert(u2.eql?(u3))
assert(!u2.equal?(u3))
assert_equal(u3, u2)
assert_send([u2, :eql?, u3])
refute_same(u3, u2)
end

def test_parse_rfc2396_parser
Expand Down
16 changes: 8 additions & 8 deletions test/uri/test_ws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def test_normalize
host = 'aBcD'
u1 = URI.parse('ws://' + host + '/eFg?HiJ')
u2 = URI.parse('ws://' + host.downcase + '/eFg?HiJ')
assert(u1.normalize.host == 'abcd')
assert(u1.normalize.path == u1.path)
assert(u1.normalize == u2.normalize)
assert(!u1.normalize.host.equal?(u1.host))
assert( u2.normalize.host.equal?(u2.host))
assert_equal('abcd', u1.normalize.host)
assert_equal(u1.path, u1.normalize.path)
assert_equal(u2.normalize, u1.normalize)
refute_same(u1.host, u1.normalize.host)
assert_same(u2.host, u2.normalize.host)

assert_equal('ws://abc/', URI.parse('ws://abc').normalize.to_s)
end

def test_equal
assert(URI.parse('ws://abc') == URI.parse('ws://ABC'))
assert(URI.parse('ws://abc/def') == URI.parse('ws://ABC/def'))
assert(URI.parse('ws://abc/def') != URI.parse('ws://ABC/DEF'))
assert_equal(URI.parse('ws://ABC'), URI.parse('ws://abc'))
assert_equal(URI.parse('ws://ABC/def'), URI.parse('ws://abc/def'))
refute_equal(URI.parse('ws://ABC/DEF'), URI.parse('ws://abc/def'))
end

def test_request_uri
Expand Down
16 changes: 8 additions & 8 deletions test/uri/test_wss.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ def test_normalize
host = 'aBcD'
u1 = URI.parse('wss://' + host + '/eFg?HiJ')
u2 = URI.parse('wss://' + host.downcase + '/eFg?HiJ')
assert(u1.normalize.host == 'abcd')
assert(u1.normalize.path == u1.path)
assert(u1.normalize == u2.normalize)
assert(!u1.normalize.host.equal?(u1.host))
assert( u2.normalize.host.equal?(u2.host))
assert_equal('abcd', u1.normalize.host)
assert_equal(u1.path, u1.normalize.path)
assert_equal(u2.normalize, u1.normalize)
refute_same(u1.host, u1.normalize.host)
assert_same(u2.host, u2.normalize.host)

assert_equal('wss://abc/', URI.parse('wss://abc').normalize.to_s)
end

def test_equal
assert(URI.parse('wss://abc') == URI.parse('wss://ABC'))
assert(URI.parse('wss://abc/def') == URI.parse('wss://ABC/def'))
assert(URI.parse('wss://abc/def') != URI.parse('wss://ABC/DEF'))
assert_equal(URI.parse('wss://ABC'), URI.parse('wss://abc'))
assert_equal(URI.parse('wss://ABC/def'), URI.parse('wss://abc/def'))
refute_equal(URI.parse('wss://ABC/DEF'), URI.parse('wss://abc/def'))
end

def test_request_uri
Expand Down