|
4 | 4 |
|
5 | 5 | RSpec.describe AutoHtml::YouTube do
|
6 | 6 | it 'transforms youtube url' do
|
7 |
| - result = subject.call('https://www.youtube.com/watch?v=BwNrmYRiX_o') |
| 7 | + result = subject.call('http://www.youtube.com/watch?v=BwNrmYRiX_o') |
8 | 8 | expect(result).to eq '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen="yes"></iframe></div>'
|
9 | 9 | end
|
10 | 10 |
|
11 |
| - it 'transforms youtube url in its own paragraph' do |
12 |
| - result = subject.call(%(Text above |
13 |
| -
|
14 |
| -https://www.youtube.com/watch?v=BwNrmYRiX_o |
15 |
| -
|
16 |
| -Text below)) |
17 |
| - expect(result).to eq %(Text above |
18 |
| -
|
19 |
| -<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen="yes"></iframe></div> |
20 |
| -
|
21 |
| -Text below) |
22 |
| - end |
23 |
| - |
24 | 11 | it 'transforms youtube url with lot of params' do
|
25 |
| - result = subject.call('https://www.youtube.com/watch?v=BwNrmYRiX_o&eurl=http%3A%2F%2Fvukajlija.com%2Fvideo%2Fklipovi%3Fstrana%3D6&feature=player_embedded') { youtube } |
| 12 | + result = subject.call('http://www.youtube.com/watch?v=BwNrmYRiX_o&eurl=http%3A%2F%2Fvukajlija.com%2Fvideo%2Fklipovi%3Fstrana%3D6&feature=player_embedded') { youtube } |
26 | 13 | expect(result).to eq '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen="yes"></iframe></div>'
|
27 | 14 | end
|
28 | 15 |
|
29 |
| - it 'does not transform inline YouTube URL' do |
30 |
| - result = subject.call('inline https://www.youtube.com/watch?v=fT1ahr81HLw is ignored') { youtube } |
31 |
| - expect(result).to eq 'inline https://www.youtube.com/watch?v=fT1ahr81HLw is ignored' |
| 16 | + it 'transforms youtube url ignoring text' do |
| 17 | + result = subject.call('foo http://www.youtube.com/watch?v=fT1ahr81HLw bar') { youtube } |
| 18 | + expect(result).to eq 'foo <div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen="yes"></iframe></div> bar' |
| 19 | + end |
| 20 | + |
| 21 | + it 'transforms youtube url ignoring html tags' do |
| 22 | + result = subject.call('foo http://www.youtube.com/watch?v=fT1ahr81HLw<br>bar') { youtube } |
| 23 | + expect(result).to eq 'foo <div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/fT1ahr81HLw" frameborder="0" allowfullscreen="yes"></iframe></div><br>bar' |
32 | 24 | end
|
33 | 25 |
|
34 | 26 | it 'transforms url without www' do
|
35 |
| - result = subject.call('https://youtube.com/watch?v=BwNrmYRiX_o') { youtube } |
| 27 | + result = subject.call('http://youtube.com/watch?v=BwNrmYRiX_o') { youtube } |
36 | 28 | expect(result).to eq '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen="yes"></iframe></div>'
|
37 | 29 | end
|
38 | 30 |
|
39 | 31 | it 'transforms short url' do
|
40 |
| - result = subject.call('https://www.youtu.be/BwNrmYRiX_o') |
| 32 | + result = subject.call('http://www.youtu.be/BwNrmYRiX_o') |
41 | 33 | expect(result).to eq '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/BwNrmYRiX_o" frameborder="0" allowfullscreen="yes"></iframe></div>'
|
42 | 34 | end
|
43 | 35 |
|
44 | 36 | it 'transforms short url with params' do
|
45 |
| - result = subject.call('https://youtu.be/t7NdBIA4zJg?t=1s&hd=1') |
| 37 | + result = subject.call('http://youtu.be/t7NdBIA4zJg?t=1s&hd=1') |
46 | 38 | expect(result).to eq '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen="yes"></iframe></div>'
|
47 | 39 | end
|
48 | 40 |
|
|
55 | 47 | result = subject.call('www.youtube.com/watch?v=t7NdBIA4zJg')
|
56 | 48 | expect(result).to eq '<div class="video youtube"><iframe width="420" height="315" src="//www.youtube.com/embed/t7NdBIA4zJg" frameborder="0" allowfullscreen="yes"></iframe></div>'
|
57 | 49 | end
|
58 |
| - |
59 |
| - it 'ignores url inside <pre> tag' do |
60 |
| - result = subject.call('<pre>https://www.youtube.com/watch?v=fT1ahr81HLw</pre>') { youtube } |
61 |
| - expect(result).to eq '<pre>https://www.youtube.com/watch?v=fT1ahr81HLw</pre>' |
62 |
| - end |
63 | 50 | end
|
0 commit comments