2003-10-05 02:09:26 -04:00
|
|
|
require 'test/unit'
|
2003-10-04 00:02:16 -04:00
|
|
|
require 'uri/ftp'
|
2003-10-05 02:09:26 -04:00
|
|
|
|
2003-10-04 00:02:16 -04:00
|
|
|
module URI
|
|
|
|
|
2003-10-05 02:09:26 -04:00
|
|
|
|
|
|
|
class TestFTP < Test::Unit::TestCase
|
2003-10-04 00:02:16 -04:00
|
|
|
def setup
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_parse
|
|
|
|
url = URI.parse('ftp://user:pass@host.com/abc/def')
|
|
|
|
assert_kind_of(URI::FTP, url)
|
|
|
|
|
|
|
|
exp = [
|
|
|
|
'ftp',
|
|
|
|
'user:pass', 'host.com', URI::FTP.default_port,
|
|
|
|
'/abc/def', nil,
|
|
|
|
]
|
2003-10-05 02:09:26 -04:00
|
|
|
ary = [
|
|
|
|
url.scheme, url.userinfo, url.host, url.port,
|
|
|
|
url.path, url.opaque
|
|
|
|
]
|
2003-10-04 00:02:16 -04:00
|
|
|
assert_equal(exp, ary)
|
|
|
|
|
|
|
|
assert_equal('user', url.user)
|
|
|
|
assert_equal('pass', url.password)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_select
|
|
|
|
assert_equal(['ftp', 'a.b.c', 21], URI.parse('ftp://a.b.c/').select(:scheme, :host, :port))
|
|
|
|
u = URI.parse('ftp://a.b.c/')
|
2003-10-05 02:09:26 -04:00
|
|
|
ary = u.component.collect {|c| u.send(c)}
|
|
|
|
assert_equal(ary, u.select(*u.component))
|
|
|
|
assert_raises(ArgumentError) do
|
2003-10-04 00:02:16 -04:00
|
|
|
u.select(:scheme, :host, :not_exist, :port)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2003-10-05 02:09:26 -04:00
|
|
|
|
2003-10-04 00:02:16 -04:00
|
|
|
end
|