Skip to content

Commit

Permalink
Usa assert_equal_html from Quickdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Jan 22, 2025
1 parent 1edb1b4 commit 3c616e9
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 121 deletions.
186 changes: 93 additions & 93 deletions quickdraw/sgml/attributes.test.rb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion quickdraw/sgml/callbacks.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def view_template
end

test "callbacks are called in the correct order" do
assert_equal Example.call, "<i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i>"
assert_equal_html Example.call, "<i>1</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>7</i>"
end
2 changes: 1 addition & 1 deletion quickdraw/sgml/capture.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ def view_template(&block)
"#{a} #{b} #{c}"
end

assert_equal output, "<h1>a b c</h1>"
assert_equal_html output, "<h1>a b c</h1>"
end
4 changes: 2 additions & 2 deletions quickdraw/sgml/comment.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
comment { "Hello World" }
end

assert_equal output, "<!-- Hello World -->"
assert_equal_html output, "<!-- Hello World -->"
end

test "block comment with markup" do
Expand All @@ -19,5 +19,5 @@
end
end

assert_equal output, "<!-- <h1>Hello World</h1> -->"
assert_equal_html output, "<!-- <h1>Hello World</h1> -->"
end
4 changes: 2 additions & 2 deletions quickdraw/sgml/conditional_rendering.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ def view_template
end

test do
assert_equal Example.new(render: true).call, "<h1>Hello</h1>"
assert_equal Example.new(render: false).call, ""
assert_equal_html Example.new(render: true).call, "<h1>Hello</h1>"
assert_equal_html Example.new(render: false).call, ""
end
4 changes: 2 additions & 2 deletions quickdraw/sgml/content_yielding.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def view_template
end

test "should render the test class" do
assert_equal TestClass.call, %q(<select name="test"></select><input type="text" name="other">)
assert_equal_html TestClass.call, %q(<select name="test"></select><input type="text" name="other">)
end

class OtherTestClass < Phlex::HTML
Expand All @@ -25,5 +25,5 @@ def view_template
end

test "should render the test class" do
assert_equal OtherTestClass.call, %q(<ul></ul><p>hi there</p>)
assert_equal_html OtherTestClass.call, %q(<ul></ul><p>hi there</p>)
end
10 changes: 5 additions & 5 deletions quickdraw/sgml/plain.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@

test "with string" do
output = phlex { plain "Hello, World!" }
assert_equal output, "Hello, World!"
assert_equal_html output, "Hello, World!"
end

test "with symbol" do
output = phlex { plain :hello_world }
assert_equal output, "hello_world"
assert_equal_html output, "hello_world"
end

test "with integer" do
output = phlex { plain 42 }
assert_equal output, "42"
assert_equal_html output, "42"
end

test "with float" do
output = phlex { plain 3.14 }
assert_equal output, "3.14"
assert_equal_html output, "3.14"
end

test "with nil" do
output = phlex { plain nil }
assert_equal output, ""
assert_equal_html output, ""
end

test "with invalid arguments" do
Expand Down
6 changes: 3 additions & 3 deletions quickdraw/sgml/raw.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

test "with a safe object" do
output = phlex { raw safe %(<div class="hello">&</div>) }
assert_equal output, %(<div class="hello">&</div>)
assert_equal_html output, %(<div class="hello">&</div>)
end

test "with nil" do
output = phlex { div { raw nil } }
assert_equal output, "<div></div>"
assert_equal_html output, "<div></div>"
end

test "with empty string" do
output = phlex { div { raw "" } }
assert_equal output, "<div></div>"
assert_equal_html output, "<div></div>"
end
4 changes: 2 additions & 2 deletions quickdraw/sgml/safe.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
end

assert_equal output, %(<a onclick="window.history.back()" href="javascript:window.history.back()"></a>)
assert_equal_html output, %(<a onclick="window.history.back()" href="javascript:window.history.back()"></a>)
end

test "element content blocks that return safe values" do
Expand All @@ -22,7 +22,7 @@
}
end

assert_equal output, %(<script>console.log("Hello World");</script>)
assert_equal_html output, %(<script>console.log("Hello World");</script>)
end

test "with invalid input" do
Expand Down
12 changes: 6 additions & 6 deletions quickdraw/sgml/selective_rendering.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ def view_template

test "renders the just the target fragment" do
output = StandardElementExample.new.call(fragments: ["target"])
assert_equal output, %(<h1 id="target">Hello<strong>World</strong><img src="image.jpg"></h1>)
assert_equal_html output, %(<h1 id="target">Hello<strong>World</strong><img src="image.jpg"></h1>)
end

test "works with void elements" do
output = VoidElementExample.new.call(fragments: ["target"])
assert_equal output, %(<img id="target" src="image.jpg">)
assert_equal_html output, %(<img id="target" src="image.jpg">)
end

test "supports multiple fragments" do
output = StandardElementExample.new.call(fragments: ["target", "image"])
assert_equal output, %(<h1 id="target">Hello<strong>World</strong><img src="image.jpg"></h1><img id="image" src="after.jpg">)
assert_equal_html output, %(<h1 id="target">Hello<strong>World</strong><img src="image.jpg"></h1><img id="image" src="after.jpg">)
end

test "halts early after all fragments are found" do
Expand All @@ -90,15 +90,15 @@ def view_template

test "with a capture block doesn't render the capture block" do
output = WithCaptureBlock.new.call(fragments: ["after"])
assert_equal output, %(<h1 id="after">After</h1>)
assert_equal_html output, %(<h1 id="after">After</h1>)
end

test "with a capture block renders the capture block when selected" do
output = WithCaptureBlock.new.call(fragments: ["around"])
assert_equal output, %(<div id="around">&lt;h1 id=&quot;inside&quot;&gt;Inside&lt;/h1&gt;</div>)
assert_equal_html output, %(<div id="around">&lt;h1 id=&quot;inside&quot;&gt;Inside&lt;/h1&gt;</div>)
end

test "with a capture block doesn't select from the capture block" do
output = WithCaptureBlock.new.call(fragments: ["inside"])
assert_equal output, ""
assert_equal_html output, ""
end
2 changes: 1 addition & 1 deletion quickdraw/sgml/to_proc.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ def view_template
end
end

assert_equal output, %(<article><h1>Sub</h1></article>)
assert_equal_html output, %(<article><h1>Sub</h1></article>)
end
4 changes: 2 additions & 2 deletions quickdraw/sgml/whitespace.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
div
end

assert_equal output, %(<div></div> <div></div>)
assert_equal_html output, %(<div></div> <div></div>)
end

test "whitespae around" do
Expand All @@ -21,5 +21,5 @@
div
end

assert_equal output, %(<div></div> <div></div> <div></div>)
assert_equal_html output, %(<div></div> <div></div> <div></div>)
end
2 changes: 1 addition & 1 deletion quickdraw/💪.test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ def view_template
end

test "💪" do
assert_equal Example.new.call, %(<h1>💪</h1>)
assert_equal_html Example.new.call, %(<h1>💪</h1>)
end

0 comments on commit 3c616e9

Please sign in to comment.