From 26e6372a8718e2670890dcab0db4f9adac515d3e Mon Sep 17 00:00:00 2001 From: tenderlove Date: Wed, 22 Dec 2010 23:32:57 +0000 Subject: adding tests for Net::SMTP::Response#exception_class git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/net/smtp/test_response.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'test/net/smtp/test_response.rb') diff --git a/test/net/smtp/test_response.rb b/test/net/smtp/test_response.rb index d810bf0b93..e7011e0fb5 100644 --- a/test/net/smtp/test_response.rb +++ b/test/net/smtp/test_response.rb @@ -58,6 +58,42 @@ module Net res = Response.parse("250-ubuntu-desktop\n250-SIZE 1 2 3\n250 DSN\n") assert_equal "250-ubuntu-desktop\n", res.message end + + def test_server_busy_exception + res = Response.parse("400 omg busy") + assert_equal Net::SMTPServerBusy, res.exception_class + res = Response.parse("410 omg busy") + assert_equal Net::SMTPServerBusy, res.exception_class + end + + def test_syntax_error_exception + res = Response.parse("500 omg syntax error") + assert_equal Net::SMTPSyntaxError, res.exception_class + + res = Response.parse("501 omg syntax error") + assert_equal Net::SMTPSyntaxError, res.exception_class + end + + def test_authentication_exception + res = Response.parse("530 omg auth error") + assert_equal Net::SMTPAuthenticationError, res.exception_class + + res = Response.parse("531 omg auth error") + assert_equal Net::SMTPAuthenticationError, res.exception_class + end + + def test_fatal_error + res = Response.parse("510 omg fatal error") + assert_equal Net::SMTPFatalError, res.exception_class + + res = Response.parse("511 omg fatal error") + assert_equal Net::SMTPFatalError, res.exception_class + end + + def test_default_exception + res = Response.parse("250 omg fatal error") + assert_equal Net::SMTPUnknownError, res.exception_class + end end end end -- cgit v1.2.3