summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/net/smtp.rb2
-rw-r--r--test/net/smtp/test_response.rb26
2 files changed, 27 insertions, 1 deletions
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 1d3cfa2fee..d90fcd5076 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -968,7 +968,7 @@ module Net
end
class Response
- def Response.parse(str)
+ def self.parse(str)
new(str[0,3], str)
end
diff --git a/test/net/smtp/test_response.rb b/test/net/smtp/test_response.rb
index 696a72157f..d810bf0b93 100644
--- a/test/net/smtp/test_response.rb
+++ b/test/net/smtp/test_response.rb
@@ -32,6 +32,32 @@ module Net
res = Response.parse("badstring")
assert_equal({}, res.capabilities)
end
+
+ def test_success?
+ res = Response.parse("250-ubuntu-desktop\n250-SIZE 1 2 3\n250 DSN\n")
+ assert res.success?
+ assert !res.continue?
+ end
+
+ # RFC 2821, Section 4.2.1
+ def test_continue?
+ res = Response.parse("3yz-ubuntu-desktop\n250-SIZE 1 2 3\n250 DSN\n")
+ assert !res.success?
+ assert res.continue?
+ end
+
+ def test_status_type_char
+ res = Response.parse("3yz-ubuntu-desktop\n250-SIZE 1 2 3\n250 DSN\n")
+ assert_equal '3', res.status_type_char
+
+ res = Response.parse("250-ubuntu-desktop\n250-SIZE 1 2 3\n250 DSN\n")
+ assert_equal '2', res.status_type_char
+ end
+
+ def test_message
+ res = Response.parse("250-ubuntu-desktop\n250-SIZE 1 2 3\n250 DSN\n")
+ assert_equal "250-ubuntu-desktop\n", res.message
+ end
end
end
end