module ViewComponent::SystemTestHelpers

def with_rendered_component_path(fragment, layout: false, &block)

Returns:
  • (Proc) - A block that can be used to visit the path of the inline rendered component.

Parameters:
  • layout (String) -- The (optional) layout to use.
  • fragment (Nokogiri::Fragment) -- The fragment returned from `render_inline`.
def with_rendered_component_path(fragment, layout: false, &block)
  file = Tempfile.new(
    ["rendered_#{fragment.class.name}", ".html"],
    ViewComponentsSystemTestController.temp_dir
  )
  begin
    file.write(vc_test_controller.render_to_string(html: fragment.to_html.html_safe, layout: layout))
    file.rewind
    block.call("/_system_test_entrypoint?file=#{file.path.split("/").last}")
  ensure
    file.unlink
  end
end