Skip to content

Commit 62b7d44

Browse files
committed
Fix typo, add example and specs
1 parent dfde700 commit 62b7d44

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

docs/components/legend.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ The HTML legend tag implemented in ruby.
99
This component can take 2 optional configuration params and optional content.
1010

1111
#### # id (optional)
12-
Expects a string with all ids the main should have.
12+
Expects a string with all ids the legend should have.
1313

1414
#### # class (optional)
15-
Expects a string with all classes the main should have.
15+
Expects a string with all classes the legend should have.
1616

17-
## Example
17+
## Example 1: Yield a given block
1818

1919
```ruby
2020
legend id: "foo", class: "bar" do
@@ -29,3 +29,16 @@ returns
2929
Hello World
3030
</legend>
3131
```
32+
33+
## Example 2: Render options[:text] param
34+
35+
```ruby
36+
legend id: "foo", class: "bar", text: 'Hello World'
37+
```
38+
39+
returns
40+
41+
```html
42+
<legend id="foo" class="bar">
43+
Hello World
44+
</legend>

spec/usage/components/legend_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ class ExamplePage < Matestack::Ui::Page
99

1010
def response
1111
components {
12+
legend text: 'I am simple'
13+
14+
# enhanced legend
1215
legend id: 'my-id', class: 'my-class' do
13-
plain 'Hello World' #optional content
16+
plain 'I am enhanced'
1417
end
1518
}
1619
end
@@ -22,9 +25,8 @@ def response
2225
static_output = page.html
2326

2427
expected_static_output = <<~HTML
25-
<legend id="my-id" class="my-class">
26-
Hello World
27-
</legend>
28+
<legend>I am simple</legend>
29+
<legend id="my-id" class="my-class">I am enhanced</legend>
2830
HTML
2931

3032
expect(stripped(static_output)).to include(stripped(expected_static_output))

0 commit comments

Comments
 (0)