diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-12 02:50:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-02-12 02:50:09 +0000 |
commit | 0a19e7f0a3fa1be6d31a702f0bf39477c1b16f0a (patch) | |
tree | 22444c310c4c0a960d4764b5ca145a908cafd558 | |
parent | 41784333f12e8f38f6869f4dd35ab5a710d0cffe (diff) |
net/ftp.rb: NullSocket#closed?
* net/ftp.rb: add NullSocket#closed? to fix closing not opened
connection. [Fix GH-1232]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/net/ftp.rb | 4 | ||||
-rw-r--r-- | test/net/ftp/test_ftp.rb | 8 |
3 files changed, 17 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Fri Feb 12 11:49:49 2016 Anthony Dmitriyev <antstorm@gmail.com> + + * net/ftp.rb: add NullSocket#closed? to fix closing not opened + connection. [Fix GH-1232] + Fri Feb 12 11:17:38 2016 Bogdan <bogdanvlviv@gmail.com> * re.c (rb_reg_initialize_m): [DOC] fix missing right bracket. diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index 26bca1a54a..cfd8cf7945 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -1270,6 +1270,10 @@ module Net def read_timeout=(sec) end + def closed? + true + end + def close end diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 3af00e7da9..4759772cb1 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -29,6 +29,14 @@ class FTPTest < Test::Unit::TestCase end end + def test_closed_when_not_connected + ftp = Net::FTP.new + assert_equal(true, ftp.closed?) + assert_nothing_raised(Net::FTPConnectionError) do + ftp.close + end + end + def test_connect_fail server = create_ftp_server { |sock| sock.print("421 Service not available, closing control connection.\r\n") |