net.smtp.rb.rset.patch

Eric Hodel, 05/08/2012 08:31 AM

Download (1.35 KB)

View differences:

lib/net/smtp.rb (working copy)
817 817

  
818 818
    public
819 819

  
820
    def rset
821
      getok('RSET')
822
    end
823

  
820 824
    def starttls
821 825
      getok('STARTTLS')
822 826
    end
test/net/smtp/test_smtp.rb (working copy)
1 1
require 'net/smtp'
2
require 'stringio'
2 3
require 'minitest/autorun'
3 4

  
4 5
module Net
5 6
  class TestSMTP < MiniTest::Unit::TestCase
7
    class FakeSocket
8
      def initialize out = "250 OK\n"
9
        @write_io = StringIO.new
10
        @read_io  = StringIO.new out
11
      end
12

  
13
      def writeline line
14
        @write_io.write "#{line}\r\n"
15
      end
16

  
17
      def readline
18
        line = @read_io.gets
19
        raise 'ran out of input' unless line
20
        line.chop
21
      end
22
    end
23

  
6 24
    def test_esmtp
7 25
      smtp = Net::SMTP.new 'localhost', 25
8 26
      assert smtp.esmtp
......
12 30
      assert_equal 'omg', smtp.esmtp
13 31
      assert_equal 'omg', smtp.esmtp?
14 32
    end
33

  
34
    def test_rset
35
      smtp = Net::SMTP.new 'localhost', 25
36
      smtp.instance_variable_set :@socket, FakeSocket.new
37

  
38
      assert smtp.rset
39
    end
15 40
  end
16 41
end