summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-11 17:27:03 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-11 17:27:03 +0000
commitf2a13e60d95c7be55de2fa793a186f5a63a9c142 (patch)
tree19ac92732124ef2ef83f7f968b9c4afd55bb7329
parentb1f2effda85efd03bd4ad5c06e0aae5e14f3f864 (diff)
* lib/net/smtp.rb: Added Net::SMTP#rset method to implement the SMTP
RSET command. [ruby-trunk - Feature #5373] * NEWS: ditto. * test/net/smtp/test_smtp.rb: Test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--NEWS4
-rw-r--r--lib/net/smtp.rb6
-rw-r--r--test/net/smtp/test_smtp.rb25
4 files changed, 42 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b7a328d..8fc848d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Mar 12 02:25:19 2013 Eric Hodel <drbrain@segment7.net>
+
+ * lib/net/smtp.rb: Added Net::SMTP#rset method to implement the SMTP
+ RSET command. [ruby-trunk - Feature #5373]
+ * NEWS: ditto.
+ * test/net/smtp/test_smtp.rb: Test for the above.
+
Mon Mar 11 22:44:57 2013 Tanaka Akira <akr@fsij.org>
* lib/resolv-replace.rb (TCPSocket#initialize): resolve the 3rd
diff --git a/NEWS b/NEWS
index abc2156..18e145b 100644
--- a/NEWS
+++ b/NEWS
@@ -25,5 +25,9 @@ with all sufficient information, see the ChangeLog file.
The ancestors of a singleton class now include that singleton class.
=== Stdlib updates (outstanding ones only)
+
+* Net::SMTP
+ * Added Net::SMTP#rset to implement the RSET comamnd
+
=== Stdlib compatibility issues (excluding feature bug fixes)
=== C API updates
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index e525bbb..29862ea 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -815,6 +815,12 @@ module Net
public
+ # Aborts the current mail transaction
+
+ def rset
+ getok('RSET')
+ end
+
def starttls
getok('STARTTLS')
end
diff --git a/test/net/smtp/test_smtp.rb b/test/net/smtp/test_smtp.rb
index 8af6a37..0b8d657 100644
--- a/test/net/smtp/test_smtp.rb
+++ b/test/net/smtp/test_smtp.rb
@@ -1,8 +1,26 @@
require 'net/smtp'
+require 'stringio'
require 'minitest/autorun'
module Net
class TestSMTP < MiniTest::Unit::TestCase
+ class FakeSocket
+ def initialize out = "250 OK\n"
+ @write_io = StringIO.new
+ @read_io = StringIO.new out
+ end
+
+ def writeline line
+ @write_io.write "#{line}\r\n"
+ end
+
+ def readline
+ line = @read_io.gets
+ raise 'ran out of input' unless line
+ line.chop
+ end
+ end
+
def test_esmtp
smtp = Net::SMTP.new 'localhost', 25
assert smtp.esmtp
@@ -12,5 +30,12 @@ module Net
assert_equal 'omg', smtp.esmtp
assert_equal 'omg', smtp.esmtp?
end
+
+ def test_rset
+ smtp = Net::SMTP.new 'localhost', 25
+ smtp.instance_variable_set :@socket, FakeSocket.new
+
+ assert smtp.rset
+ end
end
end