summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-22 23:26:05 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-22 23:26:05 +0000
commit3971bc3c70f12a21907069d4426a3391b1e05c53 (patch)
tree9e386f7b51ee4ed71f17e347fbdea98b8bb0f534
parentd236a0ca3bf63e2c5164310a4c849beabb64f3c8 (diff)
adding more tests for Net::SMTP::Response class
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-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 1d3cfa2..d90fcd5 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 696a721..d810bf0 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