7 class TestFTP < Test::Unit::TestCase
12 url = URI.parse('ftp://user:pass@host.com/abc/def')
13 assert_kind_of(URI::FTP, url)
17 'user:pass', 'host.com', URI::FTP.default_port,
21 url.scheme, url.userinfo, url.host, url.port,
24 assert_equal(exp, ary)
26 assert_equal('user', url.user)
27 assert_equal('pass', url.password)
31 # If you think what's below is wrong, please read RubyForge bug 2055,
32 # RFC 1738 section 3.2.2, and RFC 2396.
33 u = URI.parse('ftp://ftp.example.com/foo/bar/file.ext')
34 assert(u.path == 'foo/bar/file.ext')
35 u = URI.parse('ftp://ftp.example.com//foo/bar/file.ext')
36 assert(u.path == '/foo/bar/file.ext')
37 u = URI.parse('ftp://ftp.example.com/%2Ffoo/bar/file.ext')
38 assert(u.path == '/foo/bar/file.ext')
42 # uri/ftp is conservative and uses the older RFC 1738 rules, rather than
43 # assuming everyone else has implemented RFC 2396.
44 uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
45 '/path/file.zip', 'i'])
47 'ftp://user:password@ftp.example.com/%2Fpath/file.zip;type=i')
51 assert_equal(['ftp', 'a.b.c', 21], URI.parse('ftp://a.b.c/').select(:scheme, :host, :port))
52 u = URI.parse('ftp://a.b.c/')
53 ary = u.component.collect {|c| u.send(c)}
54 assert_equal(ary, u.select(*u.component))
55 assert_raises(ArgumentError) do
56 u.select(:scheme, :host, :not_exist, :port)