@@ -177,7 +177,7 @@ def truncate(html, opts = {})
177177 it 'truncates before the length param if the break_token is before the token at "length"' do
178178 expect ( truncate ( 'This is line one. <!-- truncate --> This is line two.' ,
179179 length : 30 , break_token : '<!-- truncate -->' ) ) .
180- to eq 'This is line one.'
180+ to eq 'This is line one.... '
181181 end
182182 end
183183
@@ -195,7 +195,7 @@ def truncate(html, opts = {})
195195 it 'truncates before the length param if the break_token is before the token at "length"' do
196196 expect ( truncate ( 'This is line one. <!-- break --> This is line two.' ,
197197 length : 30 , break_token : '<!-- break -->' ) ) .
198- to eq 'This is line one.'
198+ to eq 'This is line one.... '
199199 end
200200 end
201201
@@ -213,7 +213,7 @@ def truncate(html, opts = {})
213213 it 'truncates before the length param if the break_token is before the token at "length"' do
214214 expect ( truncate ( 'This is line one. <break /> This is line two.' ,
215215 length : 30 , break_token : '<break />' ) ) .
216- to eq 'This is line one.'
216+ to eq 'This is line one.... '
217217 end
218218 end
219219
@@ -231,7 +231,7 @@ def truncate(html, opts = {})
231231 it 'truncates before the length param if the break_token is before the token at "length"' do
232232 expect ( truncate ( 'This is line one. foobar This is line two.' ,
233233 length : 30 , break_token : 'foobar' ) ) .
234- to eq 'This is line one.'
234+ to eq 'This is line one.... '
235235 end
236236 end
237237
@@ -242,4 +242,20 @@ def truncate(html, opts = {})
242242 to eq '<h1>hello <!-- stuff --> and <!-- la -->...</h1>'
243243 end
244244 end
245+
246+ context 'when truncating by break_token and using a omission' do
247+ it 'includes the default omission after the truncation' do
248+ expect ( truncate ( 'This is the time to truncate this. Do it properly!' ,
249+ length : 50 , break_token : 'truncate' ) ) .
250+ to eq 'This is the time to...'
251+ end
252+
253+ it 'includes the custom omission after the truncation' do
254+ expect ( truncate ( 'This is the time to truncate this. Do it properly!' ,
255+ length : 50 ,
256+ break_token : 'truncate' ,
257+ omission : ' <a href="path">MORE</a>' ) ) .
258+ to eq 'This is the time to <a href="path">MORE</a>'
259+ end
260+ end
245261end
0 commit comments