/
ratl_spec.rb
143 lines (120 loc) · 4.98 KB
/
ratl_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
require 'dependencies.rb'
describe Ratl do
before do
@text = <<-TEXT_MESSAGE
<hi>
On Fri, Jan 7, 2011 at 3:15 PM, Steve Ellis <sellis@pivotallabs.com> wrote:
> test comment
>
>
> On Fri, Jan 7, 2011 at 3:09 PM, ahiruubdfsu <notifications@rr.redroverhq.us> wrote:
>
>> ahiruubdfsu commented on your item.
>>
>> ahiruubdfsu wrote:
>>
>> "what is the problem?"
>>
>> You can contribute to this conversation at
>> http://rr.redroverhq.us/feeds/BFhf<http://u5347.sendgrid.org/wf/click?c=
=3DmtaC%2BHUoXVlT%2Fwsox7KDNmqfXM0HDaRARRkFtmmm4ZX01%2BMxu%2FGqfecLLs3HN1O1=
&rp=3DYqYBTUd6hvBkY7v0xB2vvcKQ8T5938jStwFdtJxJP0WML2SueBH0z9Del%2B%2FNGWRP&=
up=3DvUG8URSebFjv1oz0kxNtIZyaOLaXxrku1F%2B%2BfnYcD1%2FBR9PcqNjA7OoI4nEoFH%2=
Bl&u=3DFQhH_bm3RpiDsiguFL51Kw%2Fh0>.
>>
>>
>> This message was intended for sellis@pivotallabs.com. If you do not wish
>> to receive this type of email in the future, you can unsubscribe<http://=
u5347.sendgrid.org/wf/click?c=3DmtaC%2BHUoXVlT%2Fwsox7KDNpMW7wEbHz28cqJrzbH=
JSw%2Fq50IwnDRPjwuogzq6Bu%2BAQr084zeYQd%2FTQ5qs7RTAXCcsKGcIsnlta5EShHsWmyfU=
fS1Lz%2F3yPrsAbul8COzZcNfpcnpeGVJBdEBfYNflkw%3D%3D&rp=3DYqYBTUd6hvBkY7v0xB2=
vvcKQ8T5938jStwFdtJxJP0WML2SueBH0z9Del%2B%2FNGWRP&up=3DvUG8URSebFjv1oz0kxNt=
IZyaOLaXxrku1F%2B%2BfnYcD1%2FBR9PcqNjA7OoI4nEoFH%2Bl&u=3DFQhH_bm3RpiDsiguFL=
51Kw%2Fh1>from this type of notification.
>
>
>
TEXT_MESSAGE
@html = <<-HTML_MESSAGE
<hi><br><br><div class=3D"gmail_quote">On Fri, Jan 7, 2011 at 3:15 PM=
, Steve Ellis <span dir=3D"ltr"><<a href=3D"mailto:sellis@pivotallabs.co=
m">sellis@pivotallabs.com</a>></span> wrote:<br><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex;">
test comment<div><div></div><div class=3D"h5"><div><br><br><div class=3D"gm=
ail_quote">On Fri, Jan 7, 2011 at 3:09 PM, ahiruubdfsu <span dir=3D"ltr">&l=
t;<a href=3D"mailto:notifications@rr.redroverhq.us" target=3D"_blank">notif=
ications@rr.redroverhq.us</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
ahiruubdfsu commented on your item.
<br>
<br>
ahiruubdfsu wrote:
<br>
<br>
"what is the problem?"
<br>
<br>
You can contribute to this conversation at <a href=3D"http://u5347.sendgrid=
.org/wf/click?c=3DmtaC%2BHUoXVlT%2Fwsox7KDNmqfXM0HDaRARRkFtmmm4ZX01%2BMxu%2=
FGqfecLLs3HN1O1&rp=3DYqYBTUd6hvBkY7v0xB2vvcKQ8T5938jStwFdtJxJP0WML2SueB=
H0z9Del%2B%2FNGWRP&up=3DvUG8URSebFjv1oz0kxNtIZyaOLaXxrku1F%2B%2BfnYcD1%=
2FBR9PcqNjA7OoI4nEoFH%2Bl&u=3DFQhH_bm3RpiDsiguFL51Kw%2Fh0" target=3D"_b=
lank">http://rr.redroverhq.us/feeds/BFhf</a>.
<br>
<br>
This message was intended for <a href=3D"mailto:sellis@pivotallabs.com" tar=
get=3D"_blank">sellis@pivotallabs.com</a>. If you do not wish to receive t=
his type of email in the future, you can <a href=3D"http://u5347.sendgrid.o=
rg/wf/click?c=3DmtaC%2BHUoXVlT%2Fwsox7KDNpMW7wEbHz28cqJrzbHJSw%2Fq50IwnDRPj=
wuogzq6Bu%2BAQr084zeYQd%2FTQ5qs7RTAXCcsKGcIsnlta5EShHsWmyfUfS1Lz%2F3yPrsAbu=
l8COzZcNfpcnpeGVJBdEBfYNflkw%3D%3D&rp=3DYqYBTUd6hvBkY7v0xB2vvcKQ8T5938j=
StwFdtJxJP0WML2SueBH0z9Del%2B%2FNGWRP&up=3DvUG8URSebFjv1oz0kxNtIZyaOLaX=
xrku1F%2B%2BfnYcD1%2FBR9PcqNjA7OoI4nEoFH%2Bl&u=3DFQhH_bm3RpiDsiguFL51Kw=
%2Fh1" style=3D"color:#555" target=3D"_blank">unsubscribe</a> from this typ=
e of notification.
=20
<img alt=3D"">
</blockquote></div><br></div>
</div></div></blockquote></div><br>
--000e0cdf1796fd46080499b2f7a9--
HTML_MESSAGE
end
describe ".splitter" do
it "builds a new Ratl and calls splitter on it" do
ratl = mock(:ratl)
Ratl.should_receive(:new).with(@text).and_return(ratl)
ratl.should_receive(:splitter)
Ratl.splitter(@text)
end
end
describe "MARKERS" do
context "correctly matches" do
it "GMAILs" do
message = "Here \nOn Fri, Jan 7, 2011 at 3:09 PM, ahiruubdfsu <notifications@rr.redroverhq.us> wrote: stuff"
debugger
Ratl.new(message).splitter(Markers::GMAIL).should == "Here"
end
end
end
describe "#splitter" do
before do
@ratl = Ratl.new(@text)
end
it "pulls the text above the first marker" do
marker = "On Fri, Jan 7, 2011 at 3:15 PM, Steve Ellis <sellis@pivotallabs.com> wrote:"
@ratl.splitter.should_not include marker
@ratl.splitter.should include "<hi>"
end
it "removes the content-type and mime encodings" do
marker = /Content-Type: text\/plain; charset=ISO-8859-1\s*Content-Transfer-Encoding: quoted-printable/
@ratl.splitter.should_not =~ marker
@ratl.splitter.should include "<hi>"
end
it "uses the shortest possible message" do
@ratl.splitter.should include "<hi>"
@ratl.splitter.should_not include "test comment"
end
end
end