forked from mikel/mail
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to use << on the results returned by the various addres…
…s fields, ie, mail.to << 'new@address' now works
- Loading branch information
Showing
5 changed files
with
61 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Mail | ||
|
||
class AddressContainer < Array | ||
|
||
def initialize(field, list = []) | ||
@field = field | ||
super(list) | ||
end | ||
|
||
def << (address) | ||
@field << address | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# encoding: utf-8 | ||
require File.join(File.dirname(File.expand_path(__FILE__)), '..', '..', '..', 'spec_helper') | ||
|
||
describe 'AddressContainer' do | ||
it "should allow you to append an address to an address field result" do | ||
m = Mail.new("To: mikel@test.lindsaar.net") | ||
m.to.should == ['mikel@test.lindsaar.net'] | ||
m.to << 'bob@test.lindsaar.net' | ||
m.to.should == ['mikel@test.lindsaar.net', 'bob@test.lindsaar.net'] | ||
end | ||
|
||
it "should handle complex addresses correctly" do | ||
m = Mail.new("From: mikel@test.lindsaar.net") | ||
m.from.should == ['mikel@test.lindsaar.net'] | ||
m.from << '"Ada Lindsaar" <ada@test.lindsaar.net>, bob@test.lindsaar.net' | ||
m.from.should == ['mikel@test.lindsaar.net', 'ada@test.lindsaar.net', 'bob@test.lindsaar.net'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters