From 2df3a091a9cf91c1a3c249de48392662a8603d86 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 4 Dec 2012 11:22:37 +0000 Subject: Add a method for setting the from address on a plain email fixture. --- spec/lib/mail_handler/mail_handler_spec.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'spec/lib/mail_handler/mail_handler_spec.rb') 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 -- cgit v1.2.3