From f2a13e60d95c7be55de2fa793a186f5a63a9c142 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 11 Mar 2013 17:27:03 +0000 Subject: * 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 --- test/net/smtp/test_smtp.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/net/smtp/test_smtp.rb') diff --git a/test/net/smtp/test_smtp.rb b/test/net/smtp/test_smtp.rb index 8af6a37d53..0b8d657559 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 -- cgit v1.2.3