summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-10 02:26:06 (GMT)
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-10 02:26:06 (GMT)
commitcd29e5fcef54d30a9f5e6308a47c9fd6d2dc1d73 (patch)
tree655be08536285daacd5893d8eb2a89c3e0ac0cad /test
parentab8dbd1082ea88b27ceb1f28c101ce75afff8cad (diff)
* lib/net/ftp.rb (chdir, delete, gettextfile, mdtm, mkdir, nlst,
putbinaryfile, puttextfile, rename, rmdir, size): support Pathname. Patch by Joe Rafaniello. [fix GH-828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/net/ftp/test_ftp.rb78
1 files changed, 78 insertions, 0 deletions
diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb
index f451c39..667a9e1 100644
--- a/test/net/ftp/test_ftp.rb
+++ b/test/net/ftp/test_ftp.rb
@@ -767,6 +767,84 @@ class FTPTest < Test::Unit::TestCase
end
end
+ def test_pathnames
+ require 'pathname'
+
+ commands = []
+ server = create_ftp_server(0.2) { |sock|
+ sock.print("220 (test_ftp).\r\n")
+ commands.push(sock.gets)
+ sock.print("331 Please specify the password.\r\n")
+ commands.push(sock.gets)
+ sock.print("230 Login successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("200 Switching to Binary mode.\r\n")
+ commands.push(sock.gets)
+ sock.print("257 'foo' directory created.\r\n")
+ commands.push(sock.gets)
+ sock.print("250 CWD command successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("250 CWD command successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("250 RMD command successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("213 test.txt Fri, 11 Jan 2013 11:20:41 -0500.\r\n")
+ commands.push(sock.gets)
+ sock.print("213 test.txt 16.\r\n")
+ commands.push(sock.gets)
+ sock.print("350 File exists, ready for destination name\r\n")
+ commands.push(sock.gets)
+ sock.print("250 RNTO command successful.\r\n")
+ commands.push(sock.gets)
+ sock.print("250 DELE command successful.\r\n")
+ }
+
+ begin
+ begin
+ dir = Pathname.new("foo")
+ file = Pathname.new("test.txt")
+ file2 = Pathname.new("test2.txt")
+ ftp = Net::FTP.new
+ ftp.connect(SERVER_ADDR, server.port)
+ ftp.login
+ ftp.mkdir(dir)
+ ftp.chdir(dir)
+ ftp.chdir("..")
+ ftp.rmdir(dir)
+ ftp.mdtm(file)
+ ftp.size(file)
+ ftp.rename(file, file2)
+ ftp.delete(file)
+
+ # TODO: These commented tests below expose the error but don't test anything:
+ # TypeError: no implicit conversion of Pathname into String
+ # ftp.nlst(dir)
+ # ftp.putbinaryfile(Pathname.new("/etc/hosts"), file2)
+ # ftp.puttextfile(Pathname.new("/etc/hosts"), file2)
+ # ftp.gettextfile(Pathname.new("/etc/hosts"), file2)
+ # ftp.getbinaryfile(Pathname.new("/etc/hosts"), file2)
+ # ftp.list(dir, dir, dir)
+
+ assert_match(/\AUSER /, commands.shift)
+ assert_match(/\APASS /, commands.shift)
+ assert_match(/\ATYPE /, commands.shift)
+ assert_match(/\AMKD /, commands.shift)
+ assert_match(/\ACWD /, commands.shift)
+ assert_match(/\ACDUP/, commands.shift)
+ assert_match(/\ARMD /, commands.shift)
+ assert_match(/\AMDTM /, commands.shift)
+ assert_match(/\ASIZE /, commands.shift)
+ assert_match(/\ARNFR /, commands.shift)
+ assert_match(/\ARNTO /, commands.shift)
+ assert_match(/\ADELE /, commands.shift)
+ ensure
+ ftp.close if ftp
+ end
+ ensure
+ server.close
+ end
+ end
+
private