Browse files

Allow string as delivery_method

Fixes #457
  • Loading branch information...
1 parent d8ae688 commit 2b79ba909dfe4e0fed035a92da0ef110ac0869cf @skyeagle skyeagle committed with Nov 15, 2012
Showing with 12 additions and 1 deletion.
  1. +1 −1 lib/mail/configuration.rb
  2. +11 −0 spec/mail/configuration_spec.rb
View
2 lib/mail/configuration.rb
@@ -26,7 +26,7 @@ def delivery_method(method = nil, settings = {})
end
def lookup_delivery_method(method)
- case method
+ case method.is_a?(String) ? method.to_sym : method
when nil
Mail::SMTP
when :smtp
View
11 spec/mail/configuration_spec.rb
@@ -12,6 +12,11 @@ def initialize(values)
describe "network configurations" do
+ it "defaults delivery_method to smtp" do
+ Mail.defaults { delivery_method nil, { :address => 'some.host' } }
+ Mail.delivery_method.settings[:address].should eq 'some.host'
+ end
+
it "should be available from the Mail.defaults method" do
Mail.defaults { delivery_method :smtp, { :address => 'some.host' } }
Mail.delivery_method.settings[:address].should eq 'some.host'
@@ -23,6 +28,12 @@ def initialize(values)
Mail.delivery_method.settings[:location].should eq "/usr/bin/sendmail"
end
+ it "should configure sendmail using a string" do
+ Mail.defaults { delivery_method 'sendmail', :location => "/usr/bin/sendmail" }
+ Mail.delivery_method.class.should eq Mail::Sendmail
+ Mail.delivery_method.settings[:location].should eq "/usr/bin/sendmail"
+ end
+
it "should configure exim" do
Mail.defaults { delivery_method :exim, :location => "/usr/bin/exim" }
Mail.delivery_method.class.should eq Mail::Exim

0 comments on commit 2b79ba9

Please sign in to comment.