forked from mikel/mail
/
return_path_field_spec.rb
57 lines (49 loc) · 1.59 KB
/
return_path_field_spec.rb
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
require 'spec_helper'
describe Mail::ReturnPathField do
it "should allow you to specify a field" do
rp = Mail::ReturnPathField.new('Return-Path: mikel@test.lindsaar.net')
rp.address.should == 'mikel@test.lindsaar.net'
end
it "should encode the addr_spec in <>" do
rp = Mail::ReturnPathField.new('Return-Path: mikel@test.lindsaar.net')
rp.encoded.should == "Return-Path: <mikel@test.lindsaar.net>\r\n"
end
it "should accept <>" do
rp = Mail::ReturnPathField.new('<>')
rp.encoded.should == "Return-Path: <>\r\n"
end
it "should set the return path" do
mail = Mail.new do
to "to@someemail.com"
from "from@someemail.com"
subject "Can't set the return-path"
return_path "bounce@someemail.com"
message_id "<1234@someemail.com>"
body "body"
end
mail.return_path.should == "bounce@someemail.com"
end
it "should set the return path" do
mail = Mail.new do
to "to@someemail.com"
from "from@someemail.com"
subject "Can't set the return-path"
return_path "bounce@someemail.com"
message_id "<1234@someemail.com>"
body "body"
end
encoded_mail = Mail.new(mail.encoded)
encoded_mail.return_path.should == "bounce@someemail.com"
end
it "should wrap the return path addr_spec in <>" do
mail = Mail.new do
to "to@someemail.com"
from "from@someemail.com"
subject "Can't set the return-path"
return_path "bounce@someemail.com"
message_id "<1234@someemail.com>"
body "body"
end
mail.encoded.should =~ /<bounce@someemail\.com>/
end
end