|
4 | 4 | describe 'Video Component', type: :feature, js: true do |
5 | 5 |
|
6 | 6 | it 'Renders a simple video tag on the page' do |
7 | | - class ExamplePage < Matestack::Ui::Page |
8 | | - def response |
9 | | - components { |
10 | | - video path: 'corgi.mp4', type: "mp4", width: 500, height: 300 |
11 | | - } |
12 | | - end |
13 | | - end |
| 7 | + class ExamplePage < Matestack::Ui::Page |
| 8 | + def response |
| 9 | + video path: 'corgi.mp4', type: "mp4", width: 500, height: 300 |
| 10 | + end |
| 11 | + end |
14 | 12 |
|
15 | | - visit '/example' |
16 | | - |
17 | | - expect(page).to have_xpath("//video[@width='500' and @height='300']") |
18 | | - expect(page).to have_content('Your browser does not support the video tag.') |
| 13 | + visit '/example' |
| 14 | + expected_html_output = <<~HTML |
| 15 | + <video height="300" width="500"> |
| 16 | + <source src="#{ActionController::Base.helpers.asset_path('corgi.mp4')}" type="video/mp4" /> |
| 17 | + Your browser does not support the video tag. |
| 18 | + </video> |
| 19 | + HTML |
19 | 20 | end |
20 | 21 |
|
21 | 22 | it 'Renders a video tag with more attributes on the page' do |
22 | | - class ExamplePage < Matestack::Ui::Page |
23 | | - def response |
24 | | - components { |
25 | | - video path: 'corgi.mp4', type: "mp4", width: 500, height: 300, autoplay: true, controls: true, loop: true, muted: true, playsinline: false, preload: 'auto' |
26 | | - } |
27 | | - end |
28 | | - end |
29 | | - |
30 | | - visit '/example' |
| 23 | + class ExamplePage < Matestack::Ui::Page |
| 24 | + def response |
| 25 | + video path: 'corgi.mp4', type: "mp4", width: 500, height: 300, autoplay: true, controls: true, loop: true, muted: true, playsinline: false, preload: 'auto' |
| 26 | + end |
| 27 | + end |
31 | 28 |
|
32 | | - expect(page).to have_xpath("//video[@width='500' and @height='300' and @autoplay and @controls and @loop and @muted and @preload='auto']") |
33 | | - expect(page).to have_content('Your browser does not support the video tag.') |
| 29 | + visit '/example' |
| 30 | + static_output = page.html |
| 31 | + expected_html_output = <<~HTML |
| 32 | + <video autoplay="autoplay" controls="controls" height="300" loop="loop" muted="muted" preload="auto" width="500"> |
| 33 | + <source src="#{ActionController::Base.helpers.asset_path('corgi.mp4')}" type="video/mp4" /> |
| 34 | + Your browser does not support the video tag. |
| 35 | + </video> |
| 36 | + HTML |
| 37 | + expect(stripped(static_output)).to include(stripped(expected_html_output)) |
34 | 38 | end |
35 | 39 | end |
0 commit comments