diff options
Diffstat (limited to 'test/net/imap/test_imap.rb')
-rw-r--r-- | test/net/imap/test_imap.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb index bc36f103e3..c164875c42 100644 --- a/test/net/imap/test_imap.rb +++ b/test/net/imap/test_imap.rb @@ -67,6 +67,7 @@ class IMAPTest < Test::Unit::TestCase end def test_starttls + imap = nil if defined?(OpenSSL) starttls_test do |port| imap = Net::IMAP.new("localhost", :port => port) @@ -74,6 +75,10 @@ class IMAPTest < Test::Unit::TestCase imap end end + ensure + if imap && !imap.disconnected? + imap.disconnect + end end private @@ -105,9 +110,12 @@ class IMAPTest < Test::Unit::TestCase end end begin - imap = yield(port) - imap.logout - imap.disconnect + begin + imap = yield(port) + imap.logout + ensure + imap.disconnect if imap + end ensure ssl_server.close end @@ -143,9 +151,12 @@ class IMAPTest < Test::Unit::TestCase end end begin - imap = yield(port) - imap.logout - imap.disconnect + begin + imap = yield(port) + imap.logout + ensure + imap.disconnect if imap + end ensure server.close end |