summaryrefslogtreecommitdiff
path: root/test/net
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-12 14:09:45 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-12 14:09:45 +0000
commit2478c7bc33b37867d8fd17e8199f524d0111f69d (patch)
tree993dc1379d5150eb8b686d813ba22bcdd445fd76 /test/net
parent2ec793ab270ab1edeab503355eb627144cc05b70 (diff)
* lib/net/ftp.rb (file?, directory?, appendable?, creatable?,
deletable?, enterable?, renamable?, listable?, directory_makable?, purgeable?, readable?, writable?): new methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/net')
-rw-r--r--test/net/ftp/test_buffered_socket.rb2
-rw-r--r--test/net/ftp/test_mlsx_entry.rb96
2 files changed, 97 insertions, 1 deletions
diff --git a/test/net/ftp/test_buffered_socket.rb b/test/net/ftp/test_buffered_socket.rb
index f9eefcd..8d7cc2e 100644
--- a/test/net/ftp/test_buffered_socket.rb
+++ b/test/net/ftp/test_buffered_socket.rb
@@ -3,7 +3,7 @@ require "test/unit"
require "ostruct"
require "stringio"
-class FTPTest < Test::Unit::TestCase
+class BufferedSocketTest < Test::Unit::TestCase
def test_gets_empty
sock = create_buffered_socket("")
assert_equal(nil, sock.gets)
diff --git a/test/net/ftp/test_mlsx_entry.rb b/test/net/ftp/test_mlsx_entry.rb
new file mode 100644
index 0000000..865cf91
--- /dev/null
+++ b/test/net/ftp/test_mlsx_entry.rb
@@ -0,0 +1,96 @@
+require "net/ftp"
+require "test/unit"
+require "ostruct"
+require "stringio"
+
+class MLSxEntryTest < Test::Unit::TestCase
+ def test_file?
+ assert_equal(true, Net::FTP::MLSxEntry.new({"type"=>"file"}, "foo").file?)
+ assert_equal(false, Net::FTP::MLSxEntry.new({"type"=>"dir"}, "foo").file?)
+ assert_equal(false, Net::FTP::MLSxEntry.new({"type"=>"cdir"}, "foo").file?)
+ assert_equal(false, Net::FTP::MLSxEntry.new({"type"=>"pdir"}, "foo").file?)
+ end
+
+ def test_directory?
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"type"=>"file"}, "foo").directory?)
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"type"=>"dir"}, "foo").directory?)
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"type"=>"cdir"}, "foo").directory?)
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"type"=>"pdir"}, "foo").directory?)
+ end
+
+ def test_appendable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"a"}, "foo").appendable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").appendable?)
+ end
+
+ def test_creatable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"c"}, "foo").creatable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").creatable?)
+ end
+
+ def test_deletable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"d"}, "foo").deletable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").deletable?)
+ end
+
+ def test_enterable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"e"}, "foo").enterable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").enterable?)
+ end
+
+ def test_renamable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"f"}, "foo").renamable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").renamable?)
+ end
+
+ def test_listable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"l"}, "foo").listable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").listable?)
+ end
+
+ def test_directory_makable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"m"}, "foo").
+ directory_makable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").
+ directory_makable?)
+ end
+
+ def test_purgeable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"p"}, "foo").purgeable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").purgeable?)
+ end
+
+ def test_readable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"r"}, "foo").readable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").readable?)
+ end
+
+ def test_writable?
+ assert_equal(true,
+ Net::FTP::MLSxEntry.new({"perm"=>"w"}, "foo").writable?)
+ assert_equal(false,
+ Net::FTP::MLSxEntry.new({"perm"=>""}, "foo").writable?)
+ end
+end