From 3cf6f16fb40d3e27940185478d0d42a7f07efe33 Mon Sep 17 00:00:00 2001
From: stephann <3025661+stephannv@users.noreply.github.com>
Date: Mon, 9 Sep 2024 09:45:46 -0300
Subject: [PATCH] refactor: Clean up some tests (#56)
---
spec/blueprint/html/attributes_parser_spec.cr | 12 ++++++------
spec/blueprint/html/builder_spec.cr | 4 ++--
spec/blueprint/html/component_registrar_spec.cr | 2 +-
spec/blueprint/html/conditional_rendering_spec.cr | 4 ++--
spec/blueprint/html/custom_elements_spec.cr | 4 ++--
spec/blueprint/html/enveloping_spec.cr | 2 +-
spec/blueprint/html/renderer_spec.cr | 6 +++---
spec/blueprint/html/utils_spec.cr | 4 ++--
spec/blueprint/html_spec.cr | 12 +++++-------
9 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/spec/blueprint/html/attributes_parser_spec.cr b/spec/blueprint/html/attributes_parser_spec.cr
index b99a43c..4c7dcc8 100644
--- a/spec/blueprint/html/attributes_parser_spec.cr
+++ b/spec/blueprint/html/attributes_parser_spec.cr
@@ -4,12 +4,12 @@ private class DummyPage
include Blueprint::HTML
private def blueprint
- div(class: "hello", id: "first") { "Normal attributes" }
- span(id: 421, float: 2.4) { "Non-string attribute values" }
- section(v_model: "user.name", "@click": "doSomething") { "Transform attribute name" }
- input(disabled: true, checked: false, outline: "true", border: "false")
- nav(aria: {target: "#home", selected: "false", enabled: true, hidden: false}) { "Nested attributes" }
- div(class: ["a", nil, "b", ["c", nil, "d"]]) { "Array attributes" }
+ div "Normal attributes", class: "hello", id: "first"
+ span "Non-string attribute values", id: 421, float: 2.4
+ section "Transform attribute name", v_model: "user.name", "@click": "doSomething"
+ input disabled: true, checked: false, outline: "true", border: "false"
+ nav "Nested attributes", aria: {target: "#home", selected: "false", enabled: true, hidden: false}
+ div "Array attributes", class: ["a", nil, "b", ["c", nil, "d"]]
end
end
diff --git a/spec/blueprint/html/builder_spec.cr b/spec/blueprint/html/builder_spec.cr
index 7894cbc..e574606 100644
--- a/spec/blueprint/html/builder_spec.cr
+++ b/spec/blueprint/html/builder_spec.cr
@@ -4,10 +4,10 @@ describe Blueprint::HTML do
describe ".build" do
it "renders given html structure" do
html = Blueprint::HTML.build do
- h1 { "Hello" }
+ h1 "Hello"
div do
- span { "World" }
+ span "World"
end
end
diff --git a/spec/blueprint/html/component_registrar_spec.cr b/spec/blueprint/html/component_registrar_spec.cr
index dc1402a..6f7e786 100644
--- a/spec/blueprint/html/component_registrar_spec.cr
+++ b/spec/blueprint/html/component_registrar_spec.cr
@@ -39,7 +39,7 @@ private class NoBlockComponent
include Blueprint::HTML
private def blueprint
- h1 { "Component without block" }
+ h1 "Component without block"
end
end
diff --git a/spec/blueprint/html/conditional_rendering_spec.cr b/spec/blueprint/html/conditional_rendering_spec.cr
index ed8d7cc..ce8128f 100644
--- a/spec/blueprint/html/conditional_rendering_spec.cr
+++ b/spec/blueprint/html/conditional_rendering_spec.cr
@@ -15,7 +15,7 @@ private class NoRenderPage
include Blueprint::HTML
private def blueprint
- h1 { "This page will not be rendered" }
+ h1 "This page will not be rendered"
end
private def blueprint(&)
@@ -31,7 +31,7 @@ private class NoRenderComponent
include Blueprint::HTML
private def blueprint
- h1 { "This component will not be rendered" }
+ h1 "This component will not be rendered"
end
private def blueprint(&)
diff --git a/spec/blueprint/html/custom_elements_spec.cr b/spec/blueprint/html/custom_elements_spec.cr
index 1da08a2..edc2143 100644
--- a/spec/blueprint/html/custom_elements_spec.cr
+++ b/spec/blueprint/html/custom_elements_spec.cr
@@ -4,7 +4,7 @@ private class DummyPage
include Blueprint::HTML
register_element :v_btn
- register_element :card, "v-card"
+ register_element :card, "MyCard"
private def blueprint
div do
@@ -37,7 +37,7 @@ describe "Blueprint::HTML custom elements registration" do
it "allows empty custom elements" do
page = DummyPage.new
expected_html = <<-HTML.strip
-
+
HTML
page.to_html.should contain expected_html
diff --git a/spec/blueprint/html/enveloping_spec.cr b/spec/blueprint/html/enveloping_spec.cr
index 8b13ba2..1a8d26d 100644
--- a/spec/blueprint/html/enveloping_spec.cr
+++ b/spec/blueprint/html/enveloping_spec.cr
@@ -22,7 +22,7 @@ end
private class IndexPage < BasePage
private def blueprint
- h1 { "Home" }
+ h1 "Home"
end
end
diff --git a/spec/blueprint/html/renderer_spec.cr b/spec/blueprint/html/renderer_spec.cr
index 13759c2..d439d75 100644
--- a/spec/blueprint/html/renderer_spec.cr
+++ b/spec/blueprint/html/renderer_spec.cr
@@ -7,13 +7,13 @@ private class DummyPage
render BasicComponent.new
render ContentComponent.new do
- span { "Passing content to component" }
+ span "Passing content to component"
end
render ComplexComponent.new do |card|
card.title { "My card" }
card.body { "Card content" }
- footer { "Footer tag" }
+ footer "Footer tag"
end
end
end
@@ -22,7 +22,7 @@ private class BasicComponent
include Blueprint::HTML
private def blueprint
- header { "Basic component" }
+ header "Basic component"
end
end
diff --git a/spec/blueprint/html/utils_spec.cr b/spec/blueprint/html/utils_spec.cr
index 765019a..950639a 100644
--- a/spec/blueprint/html/utils_spec.cr
+++ b/spec/blueprint/html/utils_spec.cr
@@ -7,10 +7,10 @@ private class DummyPage
doctype
div do
plain "Hello"
- b { "World" }
+ b "World"
end
- i { "Hi" }
+ i "Hi"
whitespace
plain "User"
diff --git a/spec/blueprint/html_spec.cr b/spec/blueprint/html_spec.cr
index 3855b50..2261ba8 100644
--- a/spec/blueprint/html_spec.cr
+++ b/spec/blueprint/html_spec.cr
@@ -8,7 +8,7 @@ private class BaseLayout
html lang: "en" do
head do
- title { "Test page" }
+ title "Test page"
meta charset: "utf-8"
meta name: "viewport", content: "width=device-width,initial-scale=1"
@@ -30,9 +30,9 @@ private class NavbarComponent
private def blueprint
nav do
ul do
- li { a(href: "/home") { "Home" } }
- li { a(href: "/about") { "About" } }
- li { a(href: "/contact") { "Contact" } }
+ li { a("Home", href: "/home") }
+ li { a("About", href: "/about") }
+ li { a("Contact", href: "/contact") }
end
end
end
@@ -51,9 +51,7 @@ private class ArticleComponent
end
def title
- div class: "p-2 text-lg font-bold" do
- @title
- end
+ div @title, class: "p-2 text-lg font-bold"
end
def body(&)