Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed body so that it will init on anything that responds to join fir…

…st or then to_s to handle arrays
  • Loading branch information...
commit 1642ba9114f22c6158c3a0544153c1c08415206c 1 parent 48d2a68
@mikel mikel authored
Showing with 9 additions and 4 deletions.
  1. +4 −3 lib/mail/body.rb
  2. +5 −1 spec/mail/body_spec.rb
View
7 lib/mail/body.rb
@@ -35,12 +35,13 @@ def initialize(string = '')
if string.blank?
@raw_source = ''
else
+ # Do join first incase we have been given an Array in Ruby 1.9
if string.respond_to?(:join)
@raw_source = string.join('')
- elsif string.class == String
- @raw_source = string
+ elsif string.respond_to?(:to_s)
+ @raw_source = string.to_s
else
- raise "You can only assign a string or an object that responds_to?(:join) to a body."
+ raise "You can only assign a string or an object that responds_to? :join or :to_s to a body."
end
end
@encoding = nil
View
6 spec/mail/body_spec.rb
@@ -26,7 +26,11 @@
describe "initialization" do
it "should be instantiated" do
- doing {Mail::Body.new}.should_not raise_error
+ doing { Mail::Body.new }.should_not raise_error
+ end
+
+ it "should initialize on a nil value" do
+ doing { Mail::Body.new(nil) }.should_not raise_error
end
it "should accept text as raw source data" do
Please sign in to comment.
Something went wrong with that request. Please try again.