I just noticed that the shortcut mentioned in the Rails Edge API documentation doesn't seem to actually work as specified; the nested selector doesn't seem to be restricted to one of the returned elements.
Example:
<ol id="fruit_basket"> <li><p class="type"></p></li> <li><p class="type"></p></li> <li><p class="type"></p></li> <li><p class="type"></p></li> </ol>
Okay, standard ordered list with four list items, within each item is a p with class="apple".
According to the documentation, this should work:
assert_select "ol#fruit_basket>li" do assert_select "p.type", 1 end
This fails with "Expected at most 1 elements, found 4.
If I do it explicitly,
assert_select "ol#fruit_basket>li" do |fruits| fruits.each do |fruit| assert_select fruit, "p.type", 1 end end
It passes.
Is this a core bug, or a documentation bug? If indeed this is a bug, and I'm not just nuts, I'd be happy to work on a patch for either.
Cheers, Trey