|
2 | 2 | include Utils
|
3 | 3 |
|
4 | 4 | describe 'Link Component', type: :feature, js: true do
|
5 |
| - # does not work at all. Maybe a problem with the dummy application? |
6 |
| - # it 'Example 1' do |
7 |
| - # |
8 |
| - # class ExamplePage < Matestack::Ui::Page |
9 |
| - # |
10 |
| - # def response |
11 |
| - # components { |
12 |
| - # div id: "foo", class: "bar" do |
13 |
| - # link path: "https://matestack.org", text: 'here' |
14 |
| - # end |
15 |
| - # # div id: "foo", class: "bar" do |
16 |
| - # # link path: "https://matestack.org" do |
17 |
| - # # plain 'here' |
18 |
| - # # end |
19 |
| - # # end |
20 |
| - # |
21 |
| - # } |
22 |
| - # end |
23 |
| - # |
24 |
| - # end |
25 |
| - # |
26 |
| - # visit "/example" |
27 |
| - # |
28 |
| - # sleep 500 |
29 |
| - # static_output = page.html |
30 |
| - # |
31 |
| - # expected_static_output = <<~HTML |
32 |
| - # <div id="foo" class="bar"> |
33 |
| - # <a href="https://matestack.org">here</a> |
34 |
| - # </div> |
35 |
| - # HTML |
36 |
| - # |
37 |
| - # expect(stripped(static_output)).to ( include(stripped(expected_static_output)) ) |
38 |
| - # end |
| 5 | + |
| 6 | + it 'Example 1 - Text Option' do |
| 7 | + |
| 8 | + class ExamplePage < Matestack::Ui::Page |
| 9 | + |
| 10 | + def response |
| 11 | + components { |
| 12 | + div id: "foo", class: "bar" do |
| 13 | + link path: "https://matestack.org", text: 'here' |
| 14 | + end |
| 15 | + } |
| 16 | + end |
| 17 | + |
| 18 | + end |
| 19 | + |
| 20 | + visit "/example" |
| 21 | + |
| 22 | + static_output = page.html |
| 23 | + |
| 24 | + expected_static_output = <<~HTML |
| 25 | + <div id="foo" class="bar"> |
| 26 | + <a href="https://matestack.org">here</a> |
| 27 | + </div> |
| 28 | + HTML |
| 29 | + |
| 30 | + expect(stripped(static_output)).to ( include(stripped(expected_static_output)) ) |
| 31 | + end |
| 32 | + |
| 33 | + it 'Example 2 - Yield' do |
| 34 | + |
| 35 | + class ExamplePage < Matestack::Ui::Page |
| 36 | + |
| 37 | + def response |
| 38 | + components { |
| 39 | + div id: "foo", class: "bar" do |
| 40 | + link path: "https://matestack.org" do |
| 41 | + plain 'here' |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + } |
| 46 | + end |
| 47 | + |
| 48 | + end |
| 49 | + |
| 50 | + visit "/example" |
| 51 | + |
| 52 | + static_output = page.html |
| 53 | + |
| 54 | + expected_static_output = <<~HTML |
| 55 | + <div id="foo" class="bar"> |
| 56 | + <a href="https://matestack.org">here</a> |
| 57 | + </div> |
| 58 | + HTML |
| 59 | + |
| 60 | + expect(stripped(static_output)).to ( include(stripped(expected_static_output)) ) |
| 61 | + end |
| 62 | + |
| 63 | + it 'Example 3 - Target' do |
| 64 | + |
| 65 | + class ExamplePage < Matestack::Ui::Page |
| 66 | + |
| 67 | + def response |
| 68 | + components { |
| 69 | + div id: "foo", class: "bar" do |
| 70 | + link path: "https://matestack.org", target: "_blank" do |
| 71 | + plain 'here' |
| 72 | + end |
| 73 | + end |
| 74 | + |
| 75 | + } |
| 76 | + end |
| 77 | + |
| 78 | + end |
| 79 | + |
| 80 | + visit "/example" |
| 81 | + |
| 82 | + static_output = page.html |
| 83 | + |
| 84 | + expected_static_output = <<~HTML |
| 85 | + <div id="foo" class="bar"> |
| 86 | + <a href="https://matestack.org" target="_blank">here</a> |
| 87 | + </div> |
| 88 | + HTML |
| 89 | + |
| 90 | + expect(stripped(static_output)).to ( include(stripped(expected_static_output)) ) |
| 91 | + end |
| 92 | + |
| 93 | + it 'Example 4 - Rails Routing' do |
| 94 | + |
| 95 | + Rails.application.routes.append do |
| 96 | + get '/some_link_test_path', to: 'page_test#my_action', as: 'link_test' |
| 97 | + end |
| 98 | + Rails.application.reload_routes! |
| 99 | + |
| 100 | + class ExamplePage < Matestack::Ui::Page |
| 101 | + |
| 102 | + def response |
| 103 | + components { |
| 104 | + div id: "foo", class: "bar" do |
| 105 | + link path: :link_test_path do |
| 106 | + plain 'here' |
| 107 | + end |
| 108 | + end |
| 109 | + |
| 110 | + } |
| 111 | + end |
| 112 | + |
| 113 | + end |
| 114 | + |
| 115 | + visit "/example" |
| 116 | + |
| 117 | + static_output = page.html |
| 118 | + |
| 119 | + expected_static_output = <<~HTML |
| 120 | + <div id="foo" class="bar"> |
| 121 | + <a href="/some_link_test_path">here</a> |
| 122 | + </div> |
| 123 | + HTML |
| 124 | + |
| 125 | + expect(stripped(static_output)).to ( include(stripped(expected_static_output)) ) |
| 126 | + end |
39 | 127 |
|
40 | 128 | end
|
0 commit comments