summaryrefslogtreecommitdiff
path: root/test/uri/test_ftp.rb
diff options
context:
space:
mode:
authorakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-04 04:02:16 +0000
committerakira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-04 04:02:16 +0000
commitef5883c016d02059beff0f7c5711e54a35318b32 (patch)
tree0917473376a6608a91af0361e0c15a25c8ad10c2 /test/uri/test_ftp.rb
parentd6f70951dbf2dcdec6515ee783de539d739875dd (diff)
* test/uri/* (6 files): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/uri/test_ftp.rb')
-rw-r--r--test/uri/test_ftp.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/uri/test_ftp.rb b/test/uri/test_ftp.rb
new file mode 100644
index 0000000..123eb22
--- /dev/null
+++ b/test/uri/test_ftp.rb
@@ -0,0 +1,61 @@
+#
+# $Id$
+#
+# Copyright (c) 2001 akira yamada <akira@ruby-lang.org>
+# You can redistribute it and/or modify it under the same term as Ruby.
+#
+
+require 'runit/testcase'
+require 'runit/testsuite'
+require 'runit/cui/testrunner'
+
+require 'uri/ftp'
+module URI
+ class Generic
+ def to_ary
+ component_ary
+ end
+ end
+end
+
+class TestFTP < RUNIT::TestCase
+ 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,
+ ]
+ ary = url.to_ary
+ 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/')
+ assert_equal(u.to_ary, u.select(*u.component))
+ assert_exception(ArgumentError) do
+ u.select(:scheme, :host, :not_exist, :port)
+ end
+ end
+end
+
+if $0 == __FILE__
+ if ARGV.size == 0
+ suite = TestFTP.suite
+ else
+ suite = RUNIT::TestSuite.new
+ ARGV.each do |testmethod|
+ suite.add_test(TestFTP.new(testmethod))
+ end
+ end
+ RUNIT::CUI::TestRunner.run(suite)
+end