Really? Expressed like that in a written-by-the-client, natural
language feature file?
Anyway... I do use #within to restrict some assertions to avoid false
positives. But I wouldn't make it that specific, it only makes your
integration tests brittle. So I do:
within "#some_big_container" do
assert_contain "Foo"
end
If you really want it, you could use :nth-child or the XPath
equivalents, they should work...
Yes really. I think that it's a valid interpretation. I don't read
any ordering of which div.catchphrase it should be in.
but as I said a bit later, just to make it clearer, I'd write a
different step so that I could say
I should see "foo" within any "whatever"
or maybe within some/
>
> Anyway... I do use #within to restrict some assertions to avoid false
> positives. But I wouldn't make it that specific, it only makes your
> integration tests brittle. So I do:
>
> within "#some_big_container" do
> assert_contain "Foo"
> end
>
> If you really want it, you could use :nth-child or the XPath
> equivalents, they should work...
my whole goal is to allow what I need to express without making things
brittle. If the ordering is truly unimportant, then using :nth-child
will break if the order changes.
In fact I did use :nth-child as a workaround, and I now have to change
the story because the ordering just did in fact change.
--
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
Then maybe something like this?
def assert_contain_in_any(content, selector)
hc = HasContent.new(content)
elements = Nokogiri::HTML(last_response.body).search(selector)
assert elements.any? { |el| hc.matches?(el.inner_text) }
end