summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/net/smtp.rb12
-rw-r--r--test/net/smtp/test_smtp.rb16
3 files changed, 24 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 05ed5e89dc..341281b90c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 23 08:12:59 2010 Aaron Patterson <aaron@tenderlovemaking.com>
+
+ * lib/net/smtp.rb: refactoring Net::SMTP#esmtp= to use an
+ attr_accessor
+
Thu Dec 23 06:35:41 2010 Aaron Patterson <aaron@tenderlovemaking.com>
* lib/net/smtp.rb: Net::SMTP should close the SSL connection if the
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index 1143def104..c066bacbe4 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -229,11 +229,6 @@ module Net
"#<#{self.class} #{@address}:#{@port} started=#{@started}>"
end
- # +true+ if the SMTP object uses ESMTP (which it does by default).
- def esmtp?
- @esmtp
- end
-
#
# Set whether to use ESMTP or not. This should be done before
# calling #start. Note that if #start is called in ESMTP mode,
@@ -241,11 +236,10 @@ module Net
# object will automatically switch to plain SMTP mode and
# retry (but not vice versa).
#
- def esmtp=(bool)
- @esmtp = bool
- end
+ attr_accessor :esmtp
- alias esmtp esmtp?
+ # +true+ if the SMTP object uses ESMTP (which it does by default).
+ alias :esmtp? :esmtp
# true if server advertises STARTTLS.
# You cannot get valid value before opening SMTP session.
diff --git a/test/net/smtp/test_smtp.rb b/test/net/smtp/test_smtp.rb
new file mode 100644
index 0000000000..8af6a37d53
--- /dev/null
+++ b/test/net/smtp/test_smtp.rb
@@ -0,0 +1,16 @@
+require 'net/smtp'
+require 'minitest/autorun'
+
+module Net
+ class TestSMTP < MiniTest::Unit::TestCase
+ 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
+ end
+end