@@ -82,25 +82,27 @@ def inherited(descendant) # :nodoc:
82
82
# method, where +[FORMAT]+ corresponds to the value of the
83
83
# +format+ argument.
84
84
#
85
- # === Arguments
85
+ # By default, ActionView::TestCase defines parsers for:
86
86
#
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
92
89
#
93
- # By default, ActionView::TestCase defines a parser for :
90
+ # These pre-registered parsers also define corresponding helpers :
94
91
#
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+
97
94
#
98
- # Each pre-registered parser also defines a corresponding helper:
95
+ # ==== Parameters
99
96
#
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.
102
99
#
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
104
106
#
105
107
# test "renders HTML" do
106
108
# article = Article.create!(title: "Hello, world")
@@ -118,7 +120,7 @@ def inherited(descendant) # :nodoc:
118
120
# assert_pattern { rendered.json => { title: "Hello, world" } }
119
121
# end
120
122
#
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+ :
122
124
#
123
125
# register_parser :rss, -> rendered { RSS::Parser.parse(rendered) }
124
126
#
@@ -130,9 +132,8 @@ def inherited(descendant) # :nodoc:
130
132
# assert_equal "Hello, world", rendered.rss.items.last.title
131
133
# end
132
134
#
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+:
136
137
#
137
138
# register_parser :html, -> rendered { Capybara.string(rendered) }
138
139
#
@@ -143,6 +144,7 @@ def inherited(descendant) # :nodoc:
143
144
#
144
145
# rendered.html.assert_css "h1", text: "Hello, world"
145
146
# end
147
+ #
146
148
def register_parser ( format , callable = nil , &block )
147
149
parser = callable || block || :itself . to_proc
148
150
content_class . redefine_method ( format ) do
0 commit comments