module ActionView::TestCase::Behavior

def rendered

end
assert_pattern { rendered.json => { title: "Hello, world" } }

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

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

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

+.json+

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

render partial: article

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

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

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

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

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

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

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

+.html+

By default includes the following parsers:

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

Returns the content rendered by the last +render+ call.
def rendered
  @_rendered ||= self.class.content_class.new(@rendered)
end