Skip to content

Conversation

3v0k4
Copy link

@3v0k4 3v0k4 commented May 31, 2025

Hey!

First of all, thank you so much for your work on this gem 🙏

While working on a project, I wrote the following test:

get foo_path
assert_dom "body", /bar/
make_bar_disappear_in_the_body
get foo_path
assert_not_dom "body", /bar/

The problem is that, with the current code, the last assertion always passes (even with "bar" in the body).

This PR fixes it.

@@ -477,7 +477,8 @@ def test_feed_item_encoded_with_html_version

def test_body_not_present_in_empty_document
render_html "<div></div>"
assert_select "body", 0
error = assert_raises(ArgumentError) { assert_select "body", 0 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. Why do we need it?

Copy link
Author

@3v0k4 3v0k4 Aug 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nokogiri adds a <body> (and <html>) when it's not present. In this case, the rendered html would be <html><body><div></div></body></html>.

So asserting a count (or minimum/maximum) on <body> does not make sense. Now that I think about it, we should prolly do the same thing with <html>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants