diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/test/net/smtp/test_smtp.rb |
Fresh start
Diffstat (limited to 'jni/ruby/test/net/smtp/test_smtp.rb')
-rw-r--r-- | jni/ruby/test/net/smtp/test_smtp.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/jni/ruby/test/net/smtp/test_smtp.rb b/jni/ruby/test/net/smtp/test_smtp.rb new file mode 100644 index 0000000..748b20d --- /dev/null +++ b/jni/ruby/test/net/smtp/test_smtp.rb @@ -0,0 +1,54 @@ +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_critical + smtp = Net::SMTP.new 'localhost', 25 + + assert_raises RuntimeError do + smtp.send :critical do + raise 'fail on purpose' + end + end + + assert_kind_of Net::SMTP::Response, smtp.send(:critical), + '[Bug #9125]' + end + + def test_esmtp + smtp = Net::SMTP.new 'localhost', 25 + assert smtp.esmtp + assert smtp.esmtp? + + smtp.esmtp = 'omg' + 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 |