Skip to content

Commit a200be1

Browse files
committed
Extract selecting_no_body? to HTMLSelector.
We're only touching state that the HTMLSelector already knows about in the method, so just internalize it and nodoc it.
1 parent 007e160 commit a200be1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/rails/dom/testing/assertions/selector_assertions.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def assert_select(*args, &block)
166166

167167
selector = HTMLSelector.new(args, @selected) { nodeset document_root_element }
168168

169-
if selecting_no_body?(selector)
169+
if selector.selecting_no_body?
170170
assert true
171171
return
172172
end
@@ -284,12 +284,6 @@ def assert_size_match!(size, equals, css_selector, message = nil)
284284
end
285285
end
286286

287-
def selecting_no_body?(html_selector)
288-
# Nokogiri gives the document a body element. Which means we can't
289-
# run an assertion expecting there to not be a body.
290-
html_selector.selector == 'body' && html_selector.tests[:count] == 0
291-
end
292-
293287
def nest_selection(selection)
294288
# Set @selected to allow nested assert_select.
295289
# Can be nested several levels deep.

lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ def initialize(values, previous_selection = nil, &root_fallback)
1616
end
1717
end
1818

19+
def selecting_no_body? #:nodoc:
20+
# Nokogiri gives the document a body element. Which means we can't
21+
# run an assertion expecting there to not be a body.
22+
@selector == 'body' && @tests[:count] == 0
23+
end
24+
1925
def select
2026
filter @root.css(selector, context)
2127
end

0 commit comments

Comments
 (0)