No documentation

This module has no description. You can help the Ruby on Rails community by adding new notes.

Constants

INTERNAL_IVARS = [ :@NAME, :@failures, :@assertions, :@__io__, :@_assertion_wrapped, :@_assertions, :@_result, :@_routes, :@controller, :@_controller, :@_request, :@_config, :@_default_form_builder, :@_layouts, :@_files, :@_rendered_views, :@method_name, :@output_buffer, :@_partials, :@passed, :@rendered, :@request, :@routes, :@tagged_logger, :@_templates, :@options, :@test_passed, :@view, :@view_context_class, :@view_flow, :@_subscribers, :@html_document, ]

Attributes

[RW] rendered

Returns the content rendered by the last render call.

The returned object behaves like a string but also exposes a number of methods that allows you to parse the content string in formats registered using .register_parser.

By default includes the following parsers:

.html

Parse the rendered content String into HTML. By default, this means a Nokogiri::XML::Node.

test "renders HTML" do
  article = Article.create!(title: "Hello, world")

  render partial: "articles/article", locals: { article: article }

  assert_pattern { rendered.html.at("main h1") => { content: "Hello, world" } }
end

To parse the rendered content into a Capybara::Simple::Node, re-register an :html parser with a call to Capybara.string:

register_parser :html, -> rendered { Capybara.string(rendered) }

test "renders HTML" do
  article = Article.create!(title: "Hello, world")

  render partial: article

  rendered.html.assert_css "h1", text: "Hello, world"
end

.json

Parse the rendered content String into JSON. By default, this means a ActiveSupport::HashWithIndifferentAccess.

test "renders JSON" do
  article = Article.create!(title: "Hello, world")

  render formats: :json, partial: "articles/article", locals: { article: article }

  assert_pattern { rendered.json => { title: "Hello, world" } }
end
[RW] output_buffer
[RW] request
[RW] controller
Show files where this module is defined (1 file)
Register or log in to add new notes.