1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
require 'spec_helper'
describe EmailSpec::MailExt do
describe "#default_part" do
it "prefers html_part over text_part" do
email = Mail.new do
text_part { body "This is text" }
html_part { body "This is html" }
end
expect(email.default_part.body.to_s).to eq("This is html")
end
it "returns text_part if html_part not available" do
email = Mail.new do
text_part { body "This is text" }
end
expect(email.default_part.body.to_s).to eq("This is text")
end
it "returns the email if not multi-part" do
email = Mail.new { body "This is the body" }
expect(email.default_part.body.to_s).to eq("This is the body")
end
end
describe "#default_part_body" do
it "returns default_part.body" do
email = Mail.new(:body => "hi")
expect(email.default_part.body).to eq(email.default_part_body)
end
it "compatible with ActiveSupport::SafeBuffer" do
email = Mail.new(:body => ActiveSupport::SafeBuffer.new("bacon & pancake"))
expect(email.default_part_body).to eq ("bacon & pancake")
end
end
describe "#html" do
it "returns the html part body" do
email = Mail.new do
html_part { body "This is html" }
end
expect(email.html).to eq("This is html")
end
it "returns a String" do
email = Mail.new do
html_part { body "This is html" }
end
expect(email.html).to be_a(String)
end
it "returns nil for mail with no html part" do
email = Mail.new
expect(email.html).to be_nil
end
end
end
|