|
1 | 1 | require_relative "../../support/utils"
|
2 | 2 | include Utils
|
3 | 3 |
|
4 |
| -describe "Q Component", type: :feature, js: true do |
| 4 | +describe 'Q Component', type: :feature, js: true do |
5 | 5 |
|
6 |
| - it "Example 1" do |
| 6 | + it 'Example 1 - yield, no options[:text]' do |
7 | 7 |
|
8 | 8 | class ExamplePage < Matestack::Ui::Page
|
9 | 9 |
|
10 | 10 | def response
|
11 | 11 | components {
|
12 |
| - #simple q |
13 |
| - q text: "A simple quote" |
| 12 | + # simple quote |
| 13 | + q do |
| 14 | + plain 'This is simple quote text' |
| 15 | + end |
14 | 16 |
|
15 |
| - # enhanced q |
16 |
| - q id: 'my-id', class: 'my-class', cite: 'www.matestack.org/example' do |
17 |
| - plain 'This is a enhanced q with text' |
| 17 | + # enhanced quote |
| 18 | + q id: 'my-id', class: 'my-class', cite: 'this is a cite' do |
| 19 | + plain 'This is a enhanced quote with text' |
18 | 20 | end
|
19 | 21 | }
|
20 | 22 | end
|
21 | 23 |
|
22 | 24 | end
|
23 | 25 |
|
24 |
| - visit "/example" |
| 26 | + visit '/example' |
| 27 | + static_output = page.html |
| 28 | + |
| 29 | + expected_static_output = <<~HTML |
| 30 | + <q>This is simple quote text</q> |
| 31 | + <q cite="this is a cite" id="my-id" class="my-class">This is a enhanced quote with text</q> |
| 32 | + HTML |
| 33 | + expect(stripped(static_output)).to include(stripped(expected_static_output)) |
| 34 | + end |
| 35 | + |
| 36 | + it 'Example 2 - render options[:text]' do |
| 37 | + |
| 38 | + class ExamplePage < Matestack::Ui::Page |
| 39 | + |
| 40 | + def response |
| 41 | + components { |
| 42 | + # simple quote |
| 43 | + q text: 'This is simple quote text' |
| 44 | + |
| 45 | + # enhanced quote |
| 46 | + q id: 'my-id', class: 'my-class', cite: 'this is a cite', text: 'This is a enhanced quote with text' |
| 47 | + } |
| 48 | + end |
| 49 | + |
| 50 | + end |
| 51 | + |
| 52 | + visit '/example' |
25 | 53 |
|
26 | 54 | static_output = page.html
|
27 | 55 |
|
28 | 56 | expected_static_output = <<~HTML
|
29 |
| - <q>A simple quote</q> |
30 |
| - <q cite="www.matestack.org/example" id="my-id" class="my-class">This is a enhanced q with text</q> |
| 57 | + <q>This is simple quote text</q> |
| 58 | + <q cite="this is a cite" id="my-id" class="my-class">This is a enhanced quote with text</q> |
31 | 59 | HTML
|
32 | 60 |
|
33 | 61 | expect(stripped(static_output)).to include(stripped(expected_static_output))
|
|
0 commit comments