Extract methods in link list component

Since we're simplifying the main method, we can use a view file instead
of the `call` method. This way we make the code more consistent with the
rest of our components, since we always use a separate file.

Doing so generates an extra newline at the end of the generated HTML, so
we need to change a couple of tests a little bit.
This commit is contained in:
Javi Martín
2021-06-26 23:14:45 +02:00
parent d0243764a2
commit 7abca09e03
3 changed files with 13 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ describe Shared::LinkListComponent, type: :component do
expect(list).to eq '<ul class="menu">' + "\n" +
'<li><a href="/">Home</a></li>' + "\n" +
'<li><a href="/info">Info</a></li>' + "\n</ul>"
'<li><a href="/info">Info</a></li>' + "\n</ul>\n"
end
it "accepts anchor tags" do
@@ -32,7 +32,7 @@ describe Shared::LinkListComponent, type: :component do
expect(list).to eq '<ul class="menu">' + "\n" +
'<li><a href="/">Home</a></li>' + "\n" +
'<li><a href="/info">Info</a></li>' + "\n</ul>"
'<li><a href="/info">Info</a></li>' + "\n</ul>\n"
end
it "accepts options for links" do