Module: Scarpe::Test::HTMLAssertions
- Defined in:
- lib/scarpe/components/unit_test_helpers.rb
Instance Method Summary collapse
-
#assert_contains_html(actual_html, expected_tag, **opts) { ... } ⇒ void
Assert that ‘actual_html` includes `expected_tag` with `opts`.
-
#assert_html(actual_html, expected_tag, **opts) { ... } ⇒ void
Assert that ‘actual_html` is the same as `expected_tag` with `opts`.
Instance Method Details
#assert_contains_html(actual_html, expected_tag, **opts) { ... } ⇒ void
This method returns an undefined value.
Assert that ‘actual_html` includes `expected_tag` with `opts`. This uses Scarpe’s HTML tag-based renderer to render the tag and options into text, and valides that the full HTML contains that tag.
252 253 254 255 256 257 258 |
# File 'lib/scarpe/components/unit_test_helpers.rb', line 252 def assert_contains_html(actual_html, expected_tag, **opts, &block) expected_html = Scarpe::Components::HTML.render do |h| h.public_send(expected_tag, opts, &block) end assert actual_html.include?(expected_html), "Expected #{actual_html.inspect} to include #{expected_html.inspect}!" end |
#assert_html(actual_html, expected_tag, **opts) { ... } ⇒ void
This method returns an undefined value.
Assert that ‘actual_html` is the same as `expected_tag` with `opts`. This uses Scarpe’s HTML tag-based renderer to render the tag and options into text, and valides that the text is the same.
233 234 235 236 237 238 239 |
# File 'lib/scarpe/components/unit_test_helpers.rb', line 233 def assert_html(actual_html, expected_tag, **opts, &block) expected_html = Scarpe::Components::HTML.render do |h| h.public_send(expected_tag, opts, &block) end assert_equal expected_html, actual_html end |