Using RSpec and Capybara to test for the existence of an element within a div with class 'foo'.
<div class="foo">
<p>Text zzz</p>
Looking for element here
</div>
<div class="foo">
<p>Text aaa</p>
Element should not exist within this div.
</div>
There are many divs with class 'foo' on the page, and I can give them different ID's based on foo's ID in the database.
But I don't know foo's ID from within the test. And, I don't want to test the parent of the divs because an element should be present in one div and absent in another.
What is the best way to test for an element in this case?