From cea73b2df9e8f8516e53a896944c05795fc35e4d Mon Sep 17 00:00:00 2001 From: shugo Date: Thu, 11 May 2017 07:56:52 +0000 Subject: net/imap: Net::IMAP#disconnect need not do anything if already disconnected git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/imap/test_imap.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/net/imap/test_imap.rb') diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index 35e5ed8982..3224da65a1 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -526,6 +526,33 @@ class IMAPTest < Test::Unit::TestCase end end + def test_disconnect + server = create_tcp_server + port = server.addr[1] + @threads << Thread.start do + sock = server.accept + begin + sock.print("* OK test server\r\n") + sock.gets + sock.print("* BYE terminating connection\r\n") + sock.print("RUBY0001 OK LOGOUT completed\r\n") + ensure + sock.close + server.close + end + end + begin + imap = Net::IMAP.new(SERVER_ADDR, :port => port) + imap.logout + imap.disconnect + assert_equal(true, imap.disconnected?) + imap.disconnect + assert_equal(true, imap.disconnected?) + ensure + imap.disconnect if imap && !imap.disconnected? + end + end + private def imaps_test -- cgit v1.2.3