diff options
-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") |