jnicklas/capybara — pull request #522 by mkdynamic (2011-10-15 09:18:39+00:00)
Title: Discussion: has_text matcher?

I have found in practice that the `has_content` matcher leads to false positives. Specifically, in the scenario of "I want to check that the page is displaying this text".

The main issue if that it matches text in any node, anywhere on the page. This includes JSON, content in the head, inside script tags (javascript, mustache templates etc.) for example.

I have found and am strongly convinced that there is a different scenario where I want to only check text that is displayed to the user, and not the pure XML notion of text in any node anywhere in the document.

Given that `has_content` has a different but also valuable usage, I propose that we add another matcher to cover the scenario above. Currently I am thinking `has_text` as a name for this.

Thoughts? Any ideas for alternative solutions? Let's discuss it.

PS. This pull request is meant as a discussion starting point vs. anything finished. It's not intended to be merged.