File tree Expand file tree Collapse file tree 3 files changed +70
-0
lines changed
app/concepts/matestack/ui/core/em Expand file tree Collapse file tree 3 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ %em {@tag_attributes}
2
+ - if options[:text].nil? && block_given?
3
+ = yield
4
+ - else
5
+ = options[:text]
Original file line number Diff line number Diff line change
1
+ module Matestack ::Ui ::Core ::Em
2
+ class Em < Matestack ::Ui ::Core ::Component ::Static
3
+
4
+ end
5
+ end
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../support/utils'
4
+ include Utils
5
+
6
+ describe 'Em Component' , type : :feature , js : true do
7
+ it 'Example 1 - yield, no options[:text]' do
8
+ class ExamplePage < Matestack ::Ui ::Page
9
+ def response
10
+ components do
11
+ # simple em tag
12
+ em do
13
+ plain 'Emphasized text'
14
+ end
15
+
16
+ # enhanced em tag
17
+ em id : 'my-id' , class : 'my-class' do
18
+ plain 'Enhanced emphasized text'
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ visit '/example'
25
+
26
+ static_output = page . html
27
+
28
+ expected_static_output = <<~HTML
29
+ < em > Emphasized text</ em >
30
+ < em id ="my-id " class ="my-class "> Enhanced emphasized text</ em >
31
+ HTML
32
+
33
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
34
+ end
35
+
36
+ it 'Example 2 - render options[:text]' do
37
+ class ExamplePage < Matestack ::Ui ::Page
38
+ def response
39
+ components do
40
+ # simple em
41
+ em text : 'Emphasized text'
42
+
43
+ # enhanced em
44
+ em id : 'my-id' , class : 'my-class' , text : 'Enhanced emphasized text'
45
+ end
46
+ end
47
+ end
48
+
49
+ visit '/example'
50
+
51
+ static_output = page . html
52
+
53
+ expected_static_output = <<~HTML
54
+ < em > Emphasized text</ em >
55
+ < em id ="my-id " class ="my-class "> Enhanced emphasized text</ em >
56
+ HTML
57
+
58
+ expect ( stripped ( static_output ) ) . to include ( stripped ( expected_static_output ) )
59
+ end
60
+ end
You can’t perform that action at this time.
0 commit comments