Skip to content

Commit 8a304dc

Browse files
Merge pull request rails#49924 from jonathanhefner/action_view-register_parser-doc-formatting
Fix formatting of `AV::TestCase.register_parser` doc [ci-skip]
2 parents 354e435 + 916c419 commit 8a304dc

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

actionview/lib/action_view/test_case.rb

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,27 @@ def inherited(descendant) # :nodoc:
8282
# method, where +[FORMAT]+ corresponds to the value of the
8383
# +format+ argument.
8484
#
85-
# === Arguments
85+
# By default, ActionView::TestCase defines parsers for:
8686
#
87-
# <tt>format</tt> - Symbol the name of the format used to render view's content
88-
# <tt>callable</tt> - Callable to parse the String. Accepts the String.
89-
# value as its only argument.
90-
# <tt>block</tt> - Block serves as the parser when the
91-
# <tt>callable</tt> is omitted.
87+
# * +:html+ - returns an instance of +Nokogiri::XML::Node+
88+
# * +:json+ - returns an instance of ActiveSupport::HashWithIndifferentAccess
9289
#
93-
# By default, ActionView::TestCase defines a parser for:
90+
# These pre-registered parsers also define corresponding helpers:
9491
#
95-
# * :html - returns an instance of Nokogiri::XML::Node
96-
# * :json - returns an instance of ActiveSupport::HashWithIndifferentAccess
92+
# * +:html+ - defines +rendered.html+
93+
# * +:json+ - defines +rendered.json+
9794
#
98-
# Each pre-registered parser also defines a corresponding helper:
95+
# ==== Parameters
9996
#
100-
# * :html - defines `rendered.html`
101-
# * :json - defines `rendered.json`
97+
# [+format+]
98+
# The name (as a +Symbol+) of the format used to render the content.
10299
#
103-
# === Examples
100+
# [+callable+]
101+
# The parser. A callable object that accepts the rendered string as
102+
# its sole argument. Alternatively, the parser can be specified as a
103+
# block.
104+
#
105+
# ==== Examples
104106
#
105107
# test "renders HTML" do
106108
# article = Article.create!(title: "Hello, world")
@@ -118,7 +120,7 @@ def inherited(descendant) # :nodoc:
118120
# assert_pattern { rendered.json => { title: "Hello, world" } }
119121
# end
120122
#
121-
# To parse the rendered content into RSS, register a call to <tt>RSS::Parser.parse</tt>:
123+
# To parse the rendered content into RSS, register a call to +RSS::Parser.parse+:
122124
#
123125
# register_parser :rss, -> rendered { RSS::Parser.parse(rendered) }
124126
#
@@ -130,9 +132,8 @@ def inherited(descendant) # :nodoc:
130132
# assert_equal "Hello, world", rendered.rss.items.last.title
131133
# end
132134
#
133-
# To parse the rendered content into a Capybara::Simple::Node,
134-
# re-register an <tt>:html</tt> parser with a call to
135-
# <tt>Capybara.string</tt>:
135+
# To parse the rendered content into a +Capybara::Simple::Node+,
136+
# re-register an +:html+ parser with a call to +Capybara.string+:
136137
#
137138
# register_parser :html, -> rendered { Capybara.string(rendered) }
138139
#
@@ -143,6 +144,7 @@ def inherited(descendant) # :nodoc:
143144
#
144145
# rendered.html.assert_css "h1", text: "Hello, world"
145146
# end
147+
#
146148
def register_parser(format, callable = nil, &block)
147149
parser = callable || block || :itself.to_proc
148150
content_class.redefine_method(format) do

0 commit comments

Comments
 (0)