Module: Scarpe::Test::HTMLAssertions

Included in:
ShoesSpecTest
Defined in:
scarpe-components/lib/scarpe/components/unit_test_helpers.rb

Instance Method Summary collapse

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.

Yields:

  • block passed to the tag method call.

See Also:

Parameters:

  • the html to compare to

  • the HTML tag, used to send a method call

  • keyword options passed to the tag method call



252
253
254
255
256
257
258
# File 'scarpe-components/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.

Yields:

  • block passed to the tag method call.

See Also:

Parameters:

  • the html to compare to

  • the HTML tag, used to send a method call

  • keyword options passed to the tag method call



233
234
235
236
237
238
239
# File 'scarpe-components/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