From f92879109e5f68cd9bbd6940ae30ccd26745f348 Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Mon, 16 Dec 2024 21:46:18 +0000 Subject: [PATCH 1/3] Assert style tests --- Gemfile | 2 +- quickdraw/caching.test.rb | 4 +- quickdraw/csv.test.rb | 14 +- quickdraw/fifo.test.rb | 6 +- quickdraw/helpers/grab.test.rb | 4 +- quickdraw/helpers/mix.test.rb | 30 +- quickdraw/html.test.rb | 3 +- quickdraw/html/doctype.test.rb | 2 +- quickdraw/html/standard_elements.test.rb | 8 +- quickdraw/html/svg.test.rb | 4 +- quickdraw/html/void_elements.test.rb | 6 +- quickdraw/kit.test.rb | 7 +- quickdraw/sgml.test.rb | 5 +- quickdraw/sgml/attributes.test.rb | 614 ++++++++----------- quickdraw/sgml/callbacks.test.rb | 2 +- quickdraw/sgml/capture.test.rb | 2 +- quickdraw/sgml/comment.test.rb | 24 +- quickdraw/sgml/conditional_rendering.test.rb | 4 +- quickdraw/sgml/content_yielding.test.rb | 4 +- quickdraw/sgml/plain.test.rb | 29 +- quickdraw/sgml/raw.test.rb | 15 +- quickdraw/sgml/safe.test.rb | 40 +- quickdraw/sgml/selective_rendering.test.rb | 33 +- quickdraw/sgml/to_proc.test.rb | 14 +- quickdraw/sgml/whitespace.test.rb | 28 +- quickdraw/svg.test.rb | 4 +- quickdraw/svg/standard_elements.test.rb | 6 +- "quickdraw/\360\237\222\252.test.rb" | 2 +- 28 files changed, 410 insertions(+), 506 deletions(-) diff --git a/Gemfile b/Gemfile index 8386398b..ca6e1012 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gemspec group :test do gem "sus" - gem "quickdraw", github: "joeldrapper/quickdraw" + gem "quickdraw", github: "joeldrapper/quickdraw", branch: "assert-style" gem "simplecov", require: false gem "selenium-webdriver" end diff --git a/quickdraw/caching.test.rb b/quickdraw/caching.test.rb index 17e6d450..a5299d02 100644 --- a/quickdraw/caching.test.rb +++ b/quickdraw/caching.test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true test "using a component without a source location" do - expect { + refute_raises do # Intentionally not passing a source location here. eval <<~RUBY class Example < Phlex::HTML @@ -9,5 +9,5 @@ def view_template end end RUBY - }.not_to_raise + end end diff --git a/quickdraw/csv.test.rb b/quickdraw/csv.test.rb index 84c4f0ad..5c9ddb36 100644 --- a/quickdraw/csv.test.rb +++ b/quickdraw/csv.test.rb @@ -39,7 +39,7 @@ def render_headers? Product.new(" Banana ", 2.00), ] - expect(Example.new(products).call) == <<~CSV + assert_equal Example.new(products).call, <<~CSV name,price Apple,1.0 " Banana ",2.0 @@ -52,7 +52,7 @@ def render_headers? Product.new("Banana ", 2.00), ] - expect(TrimWhitespace.new(products).call) == <<~CSV + assert_equal TrimWhitespace.new(products).call, <<~CSV name,price Apple,1.0 Banana,2.0 @@ -65,7 +65,7 @@ def render_headers? Product.new("Banana", "+C2"), ] - expect(EscapeCSVInjection.new(products).call) == <<~CSV + assert_equal EscapeCSVInjection.new(products).call, <<~CSV name,price Apple,"'=SUM(A1:B1)" Banana,"'+C2" @@ -78,16 +78,18 @@ def render_headers? Product.new("Banana", 2.00), ] - expect(NoHeaders.new(products).call) == <<~CSV + assert_equal NoHeaders.new(products).call, <<~CSV Apple,1.0 Banana,2.0 CSV end test "content type" do - expect(Example.new([]).content_type) == "text/csv" + assert_equal Example.new([]).content_type, "text/csv" end test "raises an error if there's no escape plan" do - expect { Base.new([]).call }.to_raise + assert_raises(RuntimeError) do + Base.new([]).call + end end diff --git a/quickdraw/fifo.test.rb b/quickdraw/fifo.test.rb index 3c5eba68..f052d2cc 100644 --- a/quickdraw/fifo.test.rb +++ b/quickdraw/fifo.test.rb @@ -7,7 +7,7 @@ fifo[i] = "a" end - expect(fifo.size) == 3 + assert_equal fifo.size, 3 end test "reading a key" do @@ -15,7 +15,7 @@ fifo[0] = "a" - expect(fifo[0]) == "a" + assert_equal fifo[0], "a" end test "ignores values that are too large" do @@ -24,5 +24,5 @@ fifo[1] = "a" * 10 fifo[2] = "a" * 11 - expect(fifo.size) == 1 + assert_equal fifo.size, 1 end diff --git a/quickdraw/helpers/grab.test.rb b/quickdraw/helpers/grab.test.rb index d648ea2b..d9e4be21 100644 --- a/quickdraw/helpers/grab.test.rb +++ b/quickdraw/helpers/grab.test.rb @@ -4,10 +4,10 @@ test "single binding" do output = grab(class: "foo") - expect(output) == "foo" + assert_equal output, "foo" end test "multiple bindings" do output = grab(class: "foo", if: "bar") - expect(output) == ["foo", "bar"] + assert_equal output, ["foo", "bar"] end diff --git a/quickdraw/helpers/mix.test.rb b/quickdraw/helpers/mix.test.rb index e5fe1922..720acd72 100644 --- a/quickdraw/helpers/mix.test.rb +++ b/quickdraw/helpers/mix.test.rb @@ -4,27 +4,27 @@ test "nil + string" do output = mix({ class: nil }, { class: "a" }) - expect(output) == { class: "a" } + assert_equal output, { class: "a" } end test "string + nil" do output = mix({ class: "a" }, { class: nil }) - expect(output) == { class: "a" } + assert_equal output, { class: "a" } end test "array + nil" do output = mix({ class: ["foo", "bar"] }, { class: nil }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "array + array" do output = mix({ class: ["foo"] }, { class: ["bar"] }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "array + set" do output = mix({ class: ["foo"] }, { class: Set["bar"] }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "array + hash" do @@ -33,12 +33,12 @@ { data: { controller: "bar" } }, ) - expect(output) == { data: { controller: "bar" } } + assert_equal output, { data: { controller: "bar" } } end test "array + string" do output = mix({ class: ["foo"] }, { class: "bar" }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "hash + hash" do @@ -47,40 +47,40 @@ { data: { controller: "bar" } }, ) - expect(output) == { data: { controller: "foo bar" } } + assert_equal output, { data: { controller: "foo bar" } } end test "string + array" do output = mix({ class: "foo" }, { class: ["bar"] }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "string + string" do output = mix({ class: "foo" }, { class: "bar" }) - expect(output) == { class: "foo bar" } + assert_equal output, { class: "foo bar" } end test "string + set" do output = mix({ class: "foo" }, { class: Set["bar"] }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "override" do output = mix({ class: "foo" }, { class!: "bar" }) - expect(output) == { class: "bar" } + assert_equal output, { class: "bar" } end test "set + set" do output = mix({ class: Set["foo"] }, { class: Set["bar"] }) - expect(output) == { class: Set["foo", "bar"] } + assert_equal output, { class: Set["foo", "bar"] } end test "set + array" do output = mix({ class: Set["foo"] }, { class: ["bar"] }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end test "set + string" do output = mix({ class: Set["foo"] }, { class: "bar" }) - expect(output) == { class: ["foo", "bar"] } + assert_equal output, { class: ["foo", "bar"] } end diff --git a/quickdraw/html.test.rb b/quickdraw/html.test.rb index be4331ab..1ef3aad3 100644 --- a/quickdraw/html.test.rb +++ b/quickdraw/html.test.rb @@ -2,5 +2,6 @@ test "content type" do component = Class.new(Phlex::HTML) - expect(component.new.content_type) == "text/html" + + assert_equal component.new.content_type, "text/html" end diff --git a/quickdraw/html/doctype.test.rb b/quickdraw/html/doctype.test.rb index efddc14d..a9607bf7 100644 --- a/quickdraw/html/doctype.test.rb +++ b/quickdraw/html/doctype.test.rb @@ -11,5 +11,5 @@ def view_template end test do - expect(Example.call) == "" + assert_equal Example.call, "" end diff --git a/quickdraw/html/standard_elements.test.rb b/quickdraw/html/standard_elements.test.rb index ef0c4708..e6fde44f 100644 --- a/quickdraw/html/standard_elements.test.rb +++ b/quickdraw/html/standard_elements.test.rb @@ -8,7 +8,7 @@ end end - expect(example.call) == %(<#{tag} class="class" id="id" disabled>

Hello

) + assert_equal example.call, %(<#{tag} class="class" id="id" disabled>

Hello

) end test "<#{tag}> with block text content and attributes" do @@ -18,7 +18,7 @@ end end - expect(example.call) == %(<#{tag} class="class" id="id" disabled>content) + assert_equal example.call, %(<#{tag} class="class" id="id" disabled>content) end test "<#{tag}> with string attribute keys" do @@ -28,7 +28,7 @@ end end - expect(example.call) == %(<#{tag} attribute_with_underscore>content) + assert_equal example.call, %(<#{tag} attribute_with_underscore>content) end test "<#{tag}> with hash attribute values" do @@ -38,6 +38,6 @@ end end - expect(example.call) == %(<#{tag} aria-hidden data-turbo-frame="_top">content) + assert_equal example.call, %(<#{tag} aria-hidden data-turbo-frame="_top">content) end end diff --git a/quickdraw/html/svg.test.rb b/quickdraw/html/svg.test.rb index 65ec0d7a..9e9bf44e 100644 --- a/quickdraw/html/svg.test.rb +++ b/quickdraw/html/svg.test.rb @@ -15,9 +15,9 @@ def view_template end test "rendering SVG without content" do - expect(ExampleWithoutContent.call) == %() + assert_equal %(), ExampleWithoutContent.call end test "rendering SVG inside HTML components" do - expect(Example.call) == %() + assert_equal %(), Example.call end diff --git a/quickdraw/html/void_elements.test.rb b/quickdraw/html/void_elements.test.rb index 44466d62..bee9d64a 100644 --- a/quickdraw/html/void_elements.test.rb +++ b/quickdraw/html/void_elements.test.rb @@ -8,7 +8,7 @@ end end - expect(example.call) == %(<#{tag} class="class" id="id" disabled>) + assert_equal(example.call, %(<#{tag} class="class" id="id" disabled>)) end test "<#{tag}> with string attribute keys" do @@ -18,7 +18,7 @@ end end - expect(example.call) == %(<#{tag} attribute_with_underscore>) + assert_equal(example.call, %(<#{tag} attribute_with_underscore>)) end test "<#{tag}> with hash attribute values" do @@ -28,6 +28,6 @@ end end - expect(example.call) == %(<#{tag} aria-hidden data-turbo-frame="_top">) + assert_equal(example.call, %(<#{tag} aria-hidden data-turbo-frame="_top">)) end end diff --git a/quickdraw/kit.test.rb b/quickdraw/kit.test.rb index c707b567..dfbc47bd 100644 --- a/quickdraw/kit.test.rb +++ b/quickdraw/kit.test.rb @@ -12,11 +12,10 @@ def view_template end test "raises when you try to render a component outside of a rendering context" do - expect { Components::SayHi("Joel") }.to_raise(RuntimeError) do |error| - expect(error.message) == "You can't call `SayHi' outside of a Phlex rendering context." - end + error = assert_raises(RuntimeError) { Components::SayHi("Joel") } + assert_equal error.message, "You can't call `SayHi' outside of a Phlex rendering context." end test "defines methods for its components" do - expect(Example.new.call) == %(

Hi Joel

Hi Joel

Inside

Hi Will

Inside
) + assert_equal Example.new.call, %(

Hi Joel

Hi Joel

Inside

Hi Will

Inside
) end diff --git a/quickdraw/sgml.test.rb b/quickdraw/sgml.test.rb index 2606124f..509d6e72 100644 --- a/quickdraw/sgml.test.rb +++ b/quickdraw/sgml.test.rb @@ -2,7 +2,7 @@ test "components render with a default blank view_template" do component = Class.new(Phlex::HTML) - expect(component.new.call) == "" + assert_equal component.new.call, "" end test "can't render a component more than once" do @@ -10,5 +10,6 @@ instance = component.new instance.call - expect { instance.call }.to_raise(Phlex::DoubleRenderError) + + assert_raises(Phlex::DoubleRenderError) { instance.call } end diff --git a/quickdraw/sgml/attributes.test.rb b/quickdraw/sgml/attributes.test.rb index 6af6da6f..169016f3 100644 --- a/quickdraw/sgml/attributes.test.rb +++ b/quickdraw/sgml/attributes.test.rb @@ -5,613 +5,519 @@ include SGMLHelper test "id attributes must be lower case symbols" do - expect { phlex { div("id" => "abc") } }.to_raise(Phlex::ArgumentError) - expect { phlex { div("ID" => "abc") } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(:ID => "abc") } }.to_raise(Phlex::ArgumentError) + assert_raises(Phlex::ArgumentError) { phlex { div("id" => "abc") } } + assert_raises(Phlex::ArgumentError) { phlex { div("ID" => "abc") } } + assert_raises(Phlex::ArgumentError) { phlex { div(:ID => "abc") } } - expect( - phlex { div(id: "abc") }, - ) == %(
) + output = phlex { div(id: "abc") } + assert_equal output, %(
) end test "*invalid*, _" do - expect { phlex { div(Object.new => "abc") } }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Attribute keys should be Strings or Symbols." + error = assert_raises(Phlex::ArgumentError) do + phlex { div(Object.new => "abc") } end + + assert_equal error.message, "Attribute keys should be Strings or Symbols." end test "unsafe event attribute" do - expect { phlex { div("onclick" => true) } }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Unsafe attribute name detected: onclick." + error = assert_raises(Phlex::ArgumentError) do + phlex { div("onclick" => true) } end + + assert_equal error.message, "Unsafe attribute name detected: onclick." end test "href with hash" do - expect { + error = assert_raises(Phlex::ArgumentError) do phlex { a(href: {}) } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Invalid attribute value for href: #{{}.inspect}." end + + assert_equal error.message, "Invalid attribute value for href: #{{}.inspect}." end test "unsafe href attribute" do - expect( - phlex { div(href: "javascript:alert('hello')") }, - ) == %(
) - - expect( - phlex { div(href: "Javascript:alert('hello')") }, - ) == %(
) - - expect( - phlex { div("href" => "javascript:alert('hello')") }, - ) == %(
) - - expect( - phlex { div("Href" => "javascript:alert('hello')") }, - ) == %(
) - - expect( - phlex { div("Href" => "javascript:javascript:alert('hello')") }, - ) == %(
) - - expect( - phlex { div(href: " \t\njavascript:alert('hello')") }, - ) == %(
) + [ + phlex { a(href: "javascript:alert('hello')") }, + phlex { a(href: "Javascript:alert('hello')") }, + phlex { a("href" => "javascript:alert('hello')") }, + phlex { a("Href" => "javascript:alert('hello')") }, + phlex { a("Href" => "javascript:javascript:alert('hello')") }, + phlex { a(href: " \t\njavascript:alert('hello')") }, + ].each do |output| + assert_equal output, %() + end end -test "unsafe attribute name with escape characters" do - expect { +test "unsafe attribute name <" do + error = assert_raises(Phlex::ArgumentError) do phlex { div("<" => true) } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Unsafe attribute name detected: <." end - expect { + assert_equal error.message, "Unsafe attribute name detected: <." +end + +test "unsafe attribute name >" do + error = assert_raises(Phlex::ArgumentError) do phlex { div(">" => true) } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Unsafe attribute name detected: >." end - expect { + assert_equal error.message, "Unsafe attribute name detected: >." +end + +test "unsafe attribute name &" do + error = assert_raises(Phlex::ArgumentError) do phlex { div("&" => true) } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Unsafe attribute name detected: &." end - expect { + assert_equal error.message, "Unsafe attribute name detected: &." +end + +test "unsafe attribute name '" do + error = assert_raises(Phlex::ArgumentError) do phlex { div("'" => true) } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Unsafe attribute name detected: '." end - expect { + assert_equal error.message, "Unsafe attribute name detected: '." +end + +test "unsafe attribute name \"" do + error = assert_raises(Phlex::ArgumentError) do phlex { div('"' => true) } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Unsafe attribute name detected: \"." end + + assert_equal error.message, "Unsafe attribute name detected: \"." end test "_, nil" do - expect( - phlex { div(attribute: nil) }, - ) == %(
) + output = phlex { div(attribute: nil) } + assert_equal output, %(
) end test "_, true" do - expect( - phlex { div(attribute: true) }, - ) == %(
) + output = phlex { div(attribute: true) } + assert_equal output, %(
) end test "_, false" do - expect( - phlex { div(attribute: false) }, - ) == %(
) + output = phlex { div(attribute: false) } + assert_equal output, %(
) end test "_, String" do - expect( - phlex { div(attribute: "") }, - ) == %(
) + with_empty_string = phlex { div(attribute: "") } + assert_equal with_empty_string, %(
) - expect( - phlex { div(attribute: "test") }, - ) == %(
) + with_regular_string = phlex { div(attribute: "test") } + assert_equal with_regular_string, %(
) - expect( - phlex { div(attribute: "with_underscores") }, - ) == %(
) + with_underscores = phlex { div(attribute: "with_underscores") } + assert_equal with_underscores, %(
) - expect( - phlex { div(attribute: "with-dashes") }, - ) == %(
) + with_dashes = phlex { div(attribute: "with-dashes") } + assert_equal with_dashes, %(
) - expect( - phlex { div(attribute: "with spaces") }, - ) == %(
) + with_spaces = phlex { div(attribute: "with spaces") } + assert_equal with_spaces, %(
) - expect( - phlex { div(attribute: "with 'single quotes'") }, - ) == %(
) + with_single_quotes = phlex { div(attribute: "with 'single quotes'") } + assert_equal with_single_quotes, %(
) - expect( - phlex { div(attribute: "with ") }, - ) == %(
) + with_html = phlex { div(attribute: "with ") } + assert_equal with_html, %(
) - expect( - phlex { div(attribute: 'with "double quotes"') }, - ) == %(
) + with_double_quotes = phlex { div(attribute: 'with "double quotes"') } + assert_equal with_double_quotes, %(
) end test "_, Symbol" do - expect( - phlex { div(attribute: :"") }, - ) == %(
) + empty_symbol = phlex { div(attribute: :"") } + assert_equal empty_symbol, %(
) - expect( - phlex { div(attribute: :test) }, - ) == %(
) + simple_symbol = phlex { div(attribute: :test) } + assert_equal simple_symbol, %(
) - expect( - phlex { div(attribute: :with_underscores) }, - ) == %(
) + symbol_with_underscores = phlex { div(attribute: :with_underscores) } + assert_equal symbol_with_underscores, %(
) - expect( - phlex { div(attribute: :"with-dashes") }, - ) == %(
) + symbol_with_dashes = phlex { div(attribute: :"with-dashes") } + assert_equal symbol_with_dashes, %(
) - expect( - phlex { div(attribute: :"with spaces") }, - ) == %(
) + symbol_with_spaces = phlex { div(attribute: :"with spaces") } + assert_equal symbol_with_spaces, %(
) - expect( - phlex { div(attribute: :"with 'single quotes'") }, - ) == %(
) + symbol_with_single_quotes = phlex { div(attribute: :"with 'single quotes'") } + assert_equal symbol_with_single_quotes, %(
) - expect( - phlex { div(attribute: :"with ") }, - ) == %(
) + symbol_with_html = phlex { div(attribute: :"with ") } + assert_equal symbol_with_html, %(
) - expect( - phlex { div(attribute: :'with "double quotes"') }, - ) == %(
) + symbol_with_double_quotes = phlex { div(attribute: :'with "double quotes"') } + assert_equal symbol_with_double_quotes, %(
) end test "_, Integer" do - expect( - phlex { div(attribute: 0) }, - ) == %(
) + output = phlex { div(attribute: 0) } + assert_equal output, %(
) - expect( - phlex { div(attribute: 42) }, - ) == %(
) + output = phlex { div(attribute: 42) } + assert_equal output, %(
) end test "_, Float" do - expect( - phlex { div(attribute: 0.0) }, - ) == %(
) + output = phlex { div(attribute: 0.0) } + assert_equal output, %(
) - expect( - phlex { div(attribute: 42.0) }, - ) == %(
) + output = phlex { div(attribute: 42.0) } + assert_equal output, %(
) - expect( - phlex { div(attribute: 1.234) }, - ) == %(
) + output = phlex { div(attribute: 1.234) } + assert_equal output, %(
) end test "_, *invalid*" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(attribute: Object.new) } - }.to_raise(Phlex::ArgumentError) + end end test "_, Array" do - expect( - phlex { div(attribute: []) }, - ) == %(
) + output = phlex { div(attribute: []) } + assert_equal output, %(
) end test "_, Array(nil)" do - expect( - phlex { div(attribute: [nil, nil, nil]) }, - ) == %(
) + output = phlex { div(attribute: [nil, nil, nil]) } + assert_equal output, %(
) end test "_, Array(String)" do - expect( - phlex { div(attribute: ["Hello", "World"]) }, - ) == %(
) + output = phlex { div(attribute: ["Hello", "World"]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: ["with_underscores", "with-dashes", "with spaces"]) }, - ) == %(
) + output = phlex { div(attribute: ["with_underscores", "with-dashes", "with spaces"]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: ["with 'single quotes'", 'with "double quotes"']) }, - ) == %(
) + output = phlex { div(attribute: ["with 'single quotes'", 'with "double quotes"']) } + assert_equal output, %(
) end test "_, Array(Symbol)" do - expect( - phlex { div(attribute: [:hello, :world]) }, - ) == %(
) + output = phlex { div(attribute: [:hello, :world]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: [:with_underscores, :"with-dashes", :"with spaces"]) }, - ) == %(
) + output = phlex { div(attribute: [:with_underscores, :"with-dashes", :"with spaces"]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: [:with, :"single quotes", :'"double quotes"']) }, - ) == %(
) + output = phlex { div(attribute: [:with, :"'single quotes'", :'"double quotes"']) } + assert_equal output, %(
) end test "_, Array(Integer)" do - expect( - phlex { div(attribute: [0, 42]) }, - ) == %(
) + output = phlex { div(attribute: [0, 42]) } + assert_equal output, %(
) end test "_, Array(Float)" do - expect( - phlex { div(attribute: [0.0, 42.0, 1.234]) }, - ) == %(
) + output = phlex { div(attribute: [0.0, 42.0, 1.234]) } + assert_equal output, %(
) end test "_, Array(Phlex::SGML::SafeObject)" do - expect( - phlex { div(attribute: [Phlex::SGML::SafeValue.new("Hello")]) }, - ) == %(
) + output = phlex { div(attribute: [Phlex::SGML::SafeValue.new("Hello")]) } + assert_equal output, %(
) end test "_, Array(String | Array)" do - expect( - phlex { div(attribute: ["hello", ["world"]]) }, - ) == %(
) + output = phlex { div(attribute: ["hello", ["world"]]) } + assert_equal output, %(
) end test "_, Array(Array | String)" do - expect( - phlex { div(attribute: [["hello"], "world"]) }, - ) == %(
) + output = phlex { div(attribute: [["hello"], "world"]) } + assert_equal output, %(
) end test "_, Array(String | EmptyArray)" do - expect( - phlex { div(attribute: ["hello", []]) }, - ) == %(
) + output = phlex { div(attribute: ["hello", []]) } + assert_equal output, %(
) end test "_, Array(*invalid*)" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(attribute: [Object.new]) } - }.to_raise(Phlex::ArgumentError) + end end test "_, Hash(Symbol, _)" do - expect( - phlex { div(attribute: { a_b_c: "world" }) }, - ) == %(
) + output = phlex { div(attribute: { a_b_c: "world" }) } + assert_equal output, %(
) - expect { phlex { div(attribute: { :'"' => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { :"'" => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { :"&" => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { :"<" => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { :">" => "a" }) } }.to_raise(Phlex::ArgumentError) + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { :'"' => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { :"'" => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { :"&" => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { :"<" => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { :">" => "a" }) } } end test "_, Hash(String, _)" do - expect( - phlex { div(attribute: { "a_b_c" => "world" }) }, - ) == %(
) + output = phlex { div(attribute: { "a_b_c" => "world" }) } + assert_equal output, %(
) - expect { phlex { div(attribute: { '"' => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { "'" => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { "&" => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { "<" => "a" }) } }.to_raise(Phlex::ArgumentError) - expect { phlex { div(attribute: { ">" => "a" }) } }.to_raise(Phlex::ArgumentError) + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { '"' => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { "'" => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { "&" => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { "<" => "a" }) } } + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { ">" => "a" }) } } end test "_, Hash(*invalid*, _)" do - expect { phlex { div(attribute: { Object.new => "a" }) } }.to_raise(Phlex::ArgumentError) + assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { Object.new => "a" }) } } end test "_, Hash(_, String)" do - expect( - phlex { div(data: { controller: "with_underscores" }) }, - ) == %(
) + with_underscores = phlex { div(data: { controller: "with_underscores" }) } + assert_equal with_underscores, %(
) - expect( - phlex { div(data: { controller: "with-dashes" }) }, - ) == %(
) + with_dashes = phlex { div(data: { controller: "with-dashes" }) } + assert_equal with_dashes, %(
) - expect( - phlex { div(data: { controller: "with spaces" }) }, - ) == %(
) + with_spaces = phlex { div(data: { controller: "with spaces" }) } + assert_equal with_spaces, %(
) - expect( - phlex { div(data: { controller: "with 'single quotes'" }) }, - ) == %(
) + with_single_quotes = phlex { div(data: { controller: "with 'single quotes'" }) } + assert_equal with_single_quotes, %(
) - expect( - phlex { div(data: { controller: "with " }) }, - ) == %(
) + with_html = phlex { div(data: { controller: "with " }) } + assert_equal with_html, %(
) - expect( - phlex { div(data: { controller: 'with "double quotes"' }) }, - ) == %(
) + with_double_quotes = phlex { div(data: { controller: 'with "double quotes"' }) } + assert_equal with_double_quotes, %(
) end test "_, Hash(_, Symbol)" do - expect( - phlex { div(data: { controller: :with_underscores }) }, - ) == %(
) + output = phlex { div(data: { controller: :with_underscores }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: :"with-dashes" }) }, - ) == %(
) + output = phlex { div(data: { controller: :"with-dashes" }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: :"with spaces" }) }, - ) == %(
) + output = phlex { div(data: { controller: :"with spaces" }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: :"with 'single quotes'" }) }, - ) == %(
) + output = phlex { div(data: { controller: :"with 'single quotes'" }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: :"with " }) }, - ) == %(
) + output = phlex { div(data: { controller: :"with " }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: :'with "double quotes"' }) }, - ) == %(
) + output = phlex { div(data: { controller: :'with "double quotes"' }) } + assert_equal output, %(
) end test "_, Hash(_, Integer)" do - expect( - phlex { div(data: { controller: 42 }) }, - ) == %(
) + output = phlex { div(data: { controller: 42 }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: 1_234 }) }, - ) == %(
) + output = phlex { div(data: { controller: 1_234 }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: 0 }) }, - ) == %(
) + output = phlex { div(data: { controller: 0 }) } + assert_equal output, %(
) end test "_, Hash(_, Float)" do - expect( - phlex { div(data: { controller: 42.0 }) }, - ) == %(
) + output = phlex { div(data: { controller: 42.0 }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: 1.234 }) }, - ) == %(
) + output = phlex { div(data: { controller: 1.234 }) } + assert_equal output, %(
) - expect( - phlex { div(data: { controller: 0.0 }) }, - ) == %(
) + output = phlex { div(data: { controller: 0.0 }) } + assert_equal output, %(
) end test "_, Hash(_, Array)" do - expect( - phlex { div(data: { controller: [1, 2, 3] }) }, - ) == %(
) + output = phlex { div(data: { controller: [1, 2, 3] }) } + assert_equal output, %(
) end test "_, Hash(_, Set)" do - expect( - phlex { div(data: { controller: Set[1, 2, 3] }) }, - ) == %(
) + output = phlex { div(data: { controller: Set[1, 2, 3] }) } + assert_equal output, %(
) end test "_, Hash(_, Hash)" do - expect( - phlex { div(data: { controller: { hello: "world" } }) }, - ) == %(
) + output = phlex { div(data: { controller: { hello: "world" } }) } + assert_equal output, %(
) end test "_, Hash(_, Phlex::SGML::SafeObject)" do - expect( - phlex { div(data: { controller: Phlex::SGML::SafeValue.new("Hello") }) }, - ) == %(
) + output = phlex { div(data: { controller: Phlex::SGML::SafeValue.new("Hello") }) } + assert_equal output, %(
) end test "_, Hash(_, false)" do - expect( - phlex { div(data: { controller: false }) }, - ) == %(
) + output = phlex { div(data: { controller: false }) } + assert_equal output, %(
) end test "_, Hash(_, nil)" do - expect( - phlex { div(data: { controller: nil }) }, - ) == %(
) + output = phlex { div(data: { controller: nil }) } + assert_equal output, %(
) end test "_, Hash(_, *invalid*)" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(data: { controller: Object.new }) } - }.to_raise(Phlex::ArgumentError) + end end test "_, Set(nil)" do - expect( - phlex { div(attribute: Set[nil, nil, nil]) }, - ) == %(
) + output = phlex { div(attribute: Set[nil, nil, nil]) } + assert_equal output, %(
) end test "_, Set(String)" do - expect( - phlex { div(attribute: Set["Hello", "World"]) }, - ) == %(
) + output = phlex { div(attribute: Set["Hello", "World"]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: Set["with_underscores", "with-dashes", "with spaces"]) }, - ) == %(
) + output = phlex { div(attribute: Set["with_underscores", "with-dashes", "with spaces"]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: Set["with 'single quotes'", 'with "double quotes"']) }, - ) == %(
) + output = phlex { div(attribute: Set["with 'single quotes'", 'with "double quotes"']) } + assert_equal output, %(
) end test "_, Set(Symbol)" do - expect( - phlex { div(attribute: Set[:hello, :world]) }, - ) == %(
) + output = phlex { div(attribute: Set[:hello, :world]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: Set[:with_underscores, :"with-dashes", :"with spaces"]) }, - ) == %(
) + output = phlex { div(attribute: Set[:with_underscores, :"with-dashes", :"with spaces"]) } + assert_equal output, %(
) - expect( - phlex { div(attribute: Set[:with, :"single quotes", :'"double quotes"']) }, - ) == %(
) + output = phlex { div(attribute: Set[:with, :"single quotes", :'"double quotes"']) } + assert_equal output, %(
) end test "_, Set(Integer)" do - expect( - phlex { div(attribute: Set[0, 42]) }, - ) == %(
) + output = phlex { div(attribute: Set[0, 42]) } + assert_equal output, %(
) end test "_, Set(Float)" do - expect( - phlex { div(attribute: Set[0.0, 42.0, 1.234]) }, - ) == %(
) + output = phlex { div(attribute: Set[0.0, 42.0, 1.234]) } + assert_equal output, %(
) end test "_, Set(Phlex::SGML::SafeObject)" do - expect( - phlex { - div(attribute: Set[ - Phlex::SGML::SafeValue.new("Hello"), - ]) - }, - ) == %(
) + output = phlex do + div(attribute: Set[Phlex::SGML::SafeValue.new("Hello")]) + end + + assert_equal output, %(
) end test "_, Set(*invalid*)" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(attribute: Set[Object.new]) } - }.to_raise(Phlex::ArgumentError) + end end test ":style, Array(nil)" do - expect( - phlex { div(style: [nil, nil, nil]) }, - ) == %(
) + output = phlex { div(style: [nil, nil, nil]) } + assert_equal output, %(
) end test ":style, Array(Symbol)" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(style: [:color_blue]) } - }.to_raise(Phlex::ArgumentError) + end end test ":style, Array(String)" do - expect( - phlex { div(style: ["color: blue;", "font-weight: bold"]) }, - ) == %(
) + output = phlex { div(style: ["color: blue;", "font-weight: bold"]) } + assert_equal output, %(
) - expect( - phlex { div(style: ["font-family: 'MonoLisa'"]) }, - ) == %(
) + output = phlex { div(style: ["font-family: 'MonoLisa'"]) } + assert_equal output, %(
) - expect( - phlex { div(style: ['font-family: "MonoLisa"']) }, - ) == %(
) + output = phlex { div(style: ['font-family: "MonoLisa"']) } + assert_equal output, %(
) end test ":style, Array(Phlex::SGML::SafeObject)" do - expect( - phlex { div(style: [Phlex::SGML::SafeValue.new("color: blue")]) }, - ) == %(
) + output = phlex { div(style: [Phlex::SGML::SafeValue.new("color: blue")]) } + assert_equal output, %(
) - expect( - phlex { div(style: [Phlex::SGML::SafeValue.new("font-weight: bold;")]) }, - ) == %(
) + output = phlex { div(style: [Phlex::SGML::SafeValue.new("font-weight: bold;")]) } + assert_equal output, %(
) end test ":style, Array(Hash)" do - expect( - phlex { div(style: [{ color: "blue" }, { font_weight: "bold", line_height: 1.5 }]) }, - ) == %(
) + output = phlex { div(style: [{ color: "blue" }, { font_weight: "bold", line_height: 1.5 }]) } + assert_equal output, %(
) end test ":style, Set(nil)" do - expect( - phlex { div(style: Set[nil]) }, - ) == %(
) + output = phlex { div(style: Set[nil]) } + assert_equal output, %(
) end test ":style, Set(String)" do - expect( - phlex { div(style: Set["color: blue"]) }, - ) == %(
) + output = phlex { div(style: Set["color: blue"]) } + assert_equal output, %(
) end test ":style, Hash(Symbol, String)" do - expect( - phlex { div(style: { color: "blue", font_weight: "bold" }) }, - ) == %(
) + output = phlex { div(style: { color: "blue", font_weight: "bold" }) } + assert_equal output, %(
) end test ":style, Hash(Symbol, Integer)" do - expect( - phlex { div(style: { line_height: 2 }) }, - ) == %(
) + output = phlex { div(style: { line_height: 2 }) } + assert_equal output, %(
) end test ":style, Hash(Symbol, Float)" do - expect( - phlex { div(style: { line_height: 1.5 }) }, - ) == %(
) + output = phlex { div(style: { line_height: 1.5 }) } + assert_equal output, %(
) end test ":style, Hash(Symbol, Symbol)" do - expect( - phlex { div(style: { flex_direction: :column_reverse }) }, - ) == %(
) + output = phlex { div(style: { flex_direction: :column_reverse }) } + assert_equal output, %(
) - expect( - phlex { div(style: { flex_direction: :'"double quotes"' }) }, - ) == %(
) + output = phlex { div(style: { flex_direction: :'"double quotes"' }) } + assert_equal output, %(
) end test ":style, Hash(Symbol, Phlex::SGML::SafeObject)" do - expect( - phlex { div(style: { color: Phlex::SGML::SafeValue.new("blue") }) }, - ) == %(
) + output = phlex { div(style: { color: Phlex::SGML::SafeValue.new("blue") }) } + assert_equal output, %(
) end test ":style, Hash(Symbol, nil)" do - expect( - phlex { div(style: { color: nil }) }, - ) == %(
) + output = phlex { div(style: { color: nil }) } + assert_equal output, %(
) end test ":style, Hash(Symbol, *invalid*)" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(style: { color: Object.new }) } - }.to_raise(Phlex::ArgumentError) + end end test ":style, Hash(String, String)" do - expect( - phlex { div(style: { "color" => "blue" }) }, - ) == %(
) + output = phlex { div(style: { "color" => "blue" }) } + assert_equal output, %(
) end test ":style, Hash(*invalid*, String)" do - expect { + assert_raises(Phlex::ArgumentError) do phlex { div(style: { Object.new => "blue" }) } - }.to_raise(Phlex::ArgumentError) + end end # This is just for coverage. diff --git a/quickdraw/sgml/callbacks.test.rb b/quickdraw/sgml/callbacks.test.rb index c21b708b..18efb6b1 100644 --- a/quickdraw/sgml/callbacks.test.rb +++ b/quickdraw/sgml/callbacks.test.rb @@ -27,5 +27,5 @@ def view_template end test "callbacks are called in the correct order" do - expect(Example.call) == ("1234567") + assert_equal Example.call, "1234567" end diff --git a/quickdraw/sgml/capture.test.rb b/quickdraw/sgml/capture.test.rb index ed4469a0..1d465d6a 100644 --- a/quickdraw/sgml/capture.test.rb +++ b/quickdraw/sgml/capture.test.rb @@ -11,5 +11,5 @@ def view_template(&block) "#{a} #{b} #{c}" end - expect(output) == "

a b c

" + assert_equal output, "

a b c

" end diff --git a/quickdraw/sgml/comment.test.rb b/quickdraw/sgml/comment.test.rb index b617e9eb..9c898b66 100644 --- a/quickdraw/sgml/comment.test.rb +++ b/quickdraw/sgml/comment.test.rb @@ -5,19 +5,19 @@ include SGMLHelper test "text comment" do - expect( - phlex { - comment { "Hello World" } - }, - ) == %() + output = phlex do + comment { "Hello World" } + end + + assert_equal output, "" end test "block comment with markup" do - expect( - phlex { - comment { - h1 { "Hello World" } - } - }, - ) == %() + output = phlex do + comment do + h1 { "Hello World" } + end + end + + assert_equal output, "" end diff --git a/quickdraw/sgml/conditional_rendering.test.rb b/quickdraw/sgml/conditional_rendering.test.rb index 21437e39..3d7c9851 100644 --- a/quickdraw/sgml/conditional_rendering.test.rb +++ b/quickdraw/sgml/conditional_rendering.test.rb @@ -13,6 +13,6 @@ def view_template end test do - expect(Example.new(render: true).call) == "

Hello

" - expect(Example.new(render: false).call) == "" + assert_equal Example.new(render: true).call, "

Hello

" + assert_equal Example.new(render: false).call, "" end diff --git a/quickdraw/sgml/content_yielding.test.rb b/quickdraw/sgml/content_yielding.test.rb index e603ab6e..6232c994 100644 --- a/quickdraw/sgml/content_yielding.test.rb +++ b/quickdraw/sgml/content_yielding.test.rb @@ -11,7 +11,7 @@ def view_template end test "should render the test class" do - expect(TestClass.call) == %q() + assert_equal TestClass.call, %q() end class OtherTestClass < Phlex::HTML @@ -25,5 +25,5 @@ def view_template end test "should render the test class" do - expect(OtherTestClass.call) == %q(

hi there

) + assert_equal OtherTestClass.call, %q(

hi there

) end diff --git a/quickdraw/sgml/plain.test.rb b/quickdraw/sgml/plain.test.rb index a200e9b8..d7a015e5 100644 --- a/quickdraw/sgml/plain.test.rb +++ b/quickdraw/sgml/plain.test.rb @@ -5,35 +5,32 @@ include SGMLHelper test "with string" do - expect( - phlex { plain "Hello, World!" }, - ) == "Hello, World!" + output = phlex { plain "Hello, World!" } + assert_equal output, "Hello, World!" end test "with symbol" do - expect( - phlex { plain :hello_world }, - ) == "hello_world" + output = phlex { plain :hello_world } + assert_equal output, "hello_world" end test "with integer" do - expect( - phlex { plain 42 }, - ) == "42" + output = phlex { plain 42 } + assert_equal output, "42" end test "with float" do - expect( - phlex { plain 3.14 }, - ) == "3.14" + output = phlex { plain 3.14 } + assert_equal output, "3.14" end test "with nil" do - expect( - phlex { plain nil }, - ) == "" + output = phlex { plain nil } + assert_equal output, "" end test "with invalid arguments" do - expect { phlex { plain [] } }.to_raise(Phlex::ArgumentError) + assert_raises(Phlex::ArgumentError) do + phlex { plain [] } + end end diff --git a/quickdraw/sgml/raw.test.rb b/quickdraw/sgml/raw.test.rb index c633f621..62dd095b 100644 --- a/quickdraw/sgml/raw.test.rb +++ b/quickdraw/sgml/raw.test.rb @@ -5,19 +5,24 @@ include SGMLHelper test "with an unsafe object" do - expect { phlex { raw "
" } }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "You passed an unsafe object to `raw`." + error = assert_raises(Phlex::ArgumentError) do + phlex { raw "
" } end + + assert_equal error.message, "You passed an unsafe object to `raw`." end test "with a safe object" do - expect(phlex { raw safe %(
&
) }) == %(
&
) + output = phlex { raw safe %(
&
) } + assert_equal output, %(
&
) end test "with nil" do - expect(phlex { div { raw nil } }) == %(
) + output = phlex { div { raw nil } } + assert_equal output, "
" end test "with empty string" do - expect(phlex { div { raw "" } }) == %(
) + output = phlex { div { raw "" } } + assert_equal output, "
" end diff --git a/quickdraw/sgml/safe.test.rb b/quickdraw/sgml/safe.test.rb index f3a622a2..76c1e000 100644 --- a/quickdraw/sgml/safe.test.rb +++ b/quickdraw/sgml/safe.test.rb @@ -5,32 +5,30 @@ include SGMLHelper test "safe attribute values" do - expect( - phlex { - a( - onclick: safe("window.history.back()"), - href: safe("javascript:window.history.back()"), - ) - }, - ) == %() + output = phlex do + a( + onclick: safe("window.history.back()"), + href: safe("javascript:window.history.back()"), + ) + end + + assert_equal output, %() end test "element content blocks that return safe values" do - expect( - phlex { - script { - safe(%(console.log("Hello World");)) - } - }, - ) == %() + output = phlex do + script { + safe(%(console.log("Hello World");)) + } + end + + assert_equal output, %() end test "with invalid input" do - expect { - phlex { - script { safe(123) } - } - }.to_raise(Phlex::ArgumentError) do |error| - expect(error.message) == "Expected a String." + error = assert_raises(Phlex::ArgumentError) do + phlex { script { safe(123) } } end + + assert_equal error.message, "Expected a String." end diff --git a/quickdraw/sgml/selective_rendering.test.rb b/quickdraw/sgml/selective_rendering.test.rb index 8ff2a6ca..9427d8e6 100644 --- a/quickdraw/sgml/selective_rendering.test.rb +++ b/quickdraw/sgml/selective_rendering.test.rb @@ -66,44 +66,39 @@ def view_template end test "renders the just the target fragment" do - expect( - StandardElementExample.new.call(fragments: ["target"]), - ) == %(

HelloWorld

) + output = StandardElementExample.new.call(fragments: ["target"]) + assert_equal output, %(

HelloWorld

) end test "works with void elements" do - expect( - VoidElementExample.new.call(fragments: ["target"]), - ) == %() + output = VoidElementExample.new.call(fragments: ["target"]) + assert_equal output, %() end test "supports multiple fragments" do - expect( - StandardElementExample.new.call(fragments: ["target", "image"]), - ) == %(

HelloWorld

) + output = StandardElementExample.new.call(fragments: ["target", "image"]) + assert_equal output, %(

HelloWorld

) end test "halts early after all fragments are found" do called = false checker = -> { called = true } StandardElementExample.new(checker).call(fragments: ["target"]) - expect(called) == false + + refute called end test "with a capture block doesn't render the capture block" do - expect( - WithCaptureBlock.new.call(fragments: ["after"]), - ) == %(

After

) + output = WithCaptureBlock.new.call(fragments: ["after"]) + assert_equal output, %(

After

) end test "with a capture block renders the capture block when selected" do - expect( - WithCaptureBlock.new.call(fragments: ["around"]), - ) == %(
<h1 id="inside">Inside</h1>
) + output = WithCaptureBlock.new.call(fragments: ["around"]) + assert_equal output, %(
<h1 id="inside">Inside</h1>
) end test "with a capture block doesn't select from the capture block" do - expect( - WithCaptureBlock.new.call(fragments: ["inside"]), - ) == "" + output = WithCaptureBlock.new.call(fragments: ["inside"]) + assert_equal output, "" end diff --git a/quickdraw/sgml/to_proc.test.rb b/quickdraw/sgml/to_proc.test.rb index 2e40aadf..2b185518 100644 --- a/quickdraw/sgml/to_proc.test.rb +++ b/quickdraw/sgml/to_proc.test.rb @@ -20,11 +20,11 @@ def view_template end test "rendering components via #to_proc" do - expect( - phlex { - render Example do |e| - e.slot(&Sub.new) - end - }, - ) == "

Sub

" + output = phlex do + render Example do |e| + e.slot(&Sub.new) + end + end + + assert_equal output, %(

Sub

) end diff --git a/quickdraw/sgml/whitespace.test.rb b/quickdraw/sgml/whitespace.test.rb index cdcfdd37..f7a8dee5 100644 --- a/quickdraw/sgml/whitespace.test.rb +++ b/quickdraw/sgml/whitespace.test.rb @@ -5,21 +5,21 @@ include SGMLHelper test "whitespae between" do - expect( - phlex { - div - whitespace - div - }, - ) == %(
) + output = phlex do + div + whitespace + div + end + + assert_equal output, %(
) end test "whitespae around" do - expect( - phlex { - div - whitespace { div } - div - }, - ) == %(
) + output = phlex do + div + whitespace { div } + div + end + + assert_equal output, %(
) end diff --git a/quickdraw/svg.test.rb b/quickdraw/svg.test.rb index 954c1705..756c76b2 100644 --- a/quickdraw/svg.test.rb +++ b/quickdraw/svg.test.rb @@ -9,10 +9,10 @@ def view_template end test do - expect(Example.call) == %() + assert_equal Example.call, %() end test "content_type" do component = Class.new(Phlex::SVG) - expect(component.new.content_type) == "image/svg+xml" + assert_equal component.new.content_type, "image/svg+xml" end diff --git a/quickdraw/svg/standard_elements.test.rb b/quickdraw/svg/standard_elements.test.rb index 77d6cef2..57276e84 100644 --- a/quickdraw/svg/standard_elements.test.rb +++ b/quickdraw/svg/standard_elements.test.rb @@ -8,7 +8,7 @@ end end - expect(example.call) == %(<#{tag} class="class" id="id" disabled>content) + assert_equal example.call, %(<#{tag} class="class" id="id" disabled>content) end test "<#{tag}> with string attribute keys" do @@ -18,7 +18,7 @@ end end - expect(example.call) == %(<#{tag} attribute_with_underscore>content) + assert_equal example.call, %(<#{tag} attribute_with_underscore>content) end test "<#{tag}> with hash attribute values" do @@ -28,6 +28,6 @@ end end - expect(example.call) == %(<#{tag} aria-hidden data-turbo-frame="_top">content) + assert_equal example.call, %(<#{tag} aria-hidden data-turbo-frame="_top">content) end end diff --git "a/quickdraw/\360\237\222\252.test.rb" "b/quickdraw/\360\237\222\252.test.rb" index 04c89bb2..4a932c40 100644 --- "a/quickdraw/\360\237\222\252.test.rb" +++ "b/quickdraw/\360\237\222\252.test.rb" @@ -7,5 +7,5 @@ def view_template end test "💪" do - expect(Example.new.call) == %(

💪

) + assert_equal Example.new.call, %(

💪

) end From eb1322361b1c53eb1d8cc11b548abeae4564740d Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Mon, 16 Dec 2024 21:48:37 +0000 Subject: [PATCH 2/3] Update sgml.test.rb --- quickdraw/sgml.test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quickdraw/sgml.test.rb b/quickdraw/sgml.test.rb index db10dd0a..e2958db5 100644 --- a/quickdraw/sgml.test.rb +++ b/quickdraw/sgml.test.rb @@ -16,7 +16,7 @@ def template end end - expect(component.new.call) == Phlex::Escape.html_escape( + assert_equal component.new.call, Phlex::Escape.html_escape( %(Phlex Warning: Your `#{component.name}` class doesn't define a `view_template` method. If you are upgrading to Phlex 2.x make sure to rename your `template` method to `view_template`. See: https://beta.phlex.fun/guides/v2-upgrade.html) ) end @@ -24,7 +24,7 @@ def template test "components with no `view_template` method render warning" do component = Class.new(Phlex::HTML) - expect(component.new.call) == Phlex::Escape.html_escape( + assert_equal component.new.call, Phlex::Escape.html_escape( %(Phlex Warning: Your `#{component.name}` class doesn't define a `view_template` method. If you are upgrading to Phlex 2.x make sure to rename your `template` method to `view_template`. See: https://beta.phlex.fun/guides/v2-upgrade.html) ) end From 860b2c922b83655adcfe1ec5bc4a490c4b827cb6 Mon Sep 17 00:00:00 2001 From: Joel Drapper Date: Mon, 16 Dec 2024 21:51:53 +0000 Subject: [PATCH 3/3] Rubocop fixes --- lib/phlex/html/standard_elements.rb | 101 ---------------------------- lib/phlex/html/void_elements.rb | 11 --- lib/phlex/svg/standard_elements.rb | 63 ----------------- 3 files changed, 175 deletions(-) diff --git a/lib/phlex/html/standard_elements.rb b/lib/phlex/html/standard_elements.rb index c267a9a6..94ae9777 100644 --- a/lib/phlex/html/standard_elements.rb +++ b/lib/phlex/html/standard_elements.rb @@ -17,7 +17,6 @@ module Phlex::HTML::StandardElements **attributes, &content ) = nil - # Outputs an `` tag. # The `` element represents an abbreviation or acronym. # See https://developer.mozilla.org/docs/Web/HTML/Element/abbr @@ -28,7 +27,6 @@ module Phlex::HTML::StandardElements **attributes, &content ) = nil - # Outputs an `
` tag. # The `
` element indicates contact information for a person or organization. # See https://developer.mozilla.org/docs/Web/HTML/Element/address @@ -38,7 +36,6 @@ module Phlex::HTML::StandardElements **attributes, &content ) = nil - # Outputs an `
` tag. # The `
` element represents a self-contained composition in a document, page, application, or site. # See https://developer.mozilla.org/docs/Web/HTML/Element/article @@ -48,7 +45,6 @@ module Phlex::HTML::StandardElements **attributes, &content ) = nil - # Outputs an `