aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2012-12-04 11:22:37 +0000
committerLouise Crow <louise.crow@gmail.com>2012-12-04 11:22:37 +0000
commit2df3a091a9cf91c1a3c249de48392662a8603d86 (patch)
treec7d03079d2ce20912fa6718d6ad671891189f382
parent41e3c41d08e97e232bb7cf2e1faec00c9aa0f92b (diff)
Add a method for setting the from address on a plain email fixture.
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index e673c5bf0..8f642d529 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -1,6 +1,12 @@
# coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
+def create_message_from(from_field)
+ mail_data = load_file_fixture('incoming-request-plain.email')
+ mail_data.gsub!('EMAIL_FROM', from_field)
+ mail = MailHandler.mail_from_raw_email(mail_data)
+end
+
describe 'when creating a mail object from raw data' do
it 'should correctly parse a multipart email with a linebreak in the boundary' do
@@ -25,9 +31,7 @@ end
describe 'when asked for the from name' do
it 'should return nil if there is a blank "From" field' do
- mail_data = load_file_fixture('incoming-request-plain.email')
- mail_data.gsub!('EMAIL_FROM', '')
- mail = MailHandler.mail_from_raw_email(mail_data)
+ mail = create_message_from('')
MailHandler.get_from_name(mail).should == nil
end
@@ -51,9 +55,7 @@ end
describe 'when asked for the from address' do
it 'should return nil if there is a blank "From" field' do
- mail_data = load_file_fixture('incoming-request-plain.email')
- mail_data.gsub!('EMAIL_FROM', '')
- mail = MailHandler.mail_from_raw_email(mail_data)
+ mail = create_message_from('')
MailHandler.get_from_address(mail).should == nil
end