I'm using RSpec/Capybara as my test suite. I have some javascript that dynamically appends <li>
to the end of a <ul>
. I want to write a request spec to ensure that this is happening.
I tried using the has_css
Capybara method and advanced CSS selectors to test for the ordering of the <li>
elements, but Capybara doesn't support the +
CSS selector.
Example:
page.should have_css('li:contains("ITEM #1")')
pseuo_add_new_li
page.should have_css('li:contains("ITEM #1")+li:contains("ITEM #2")')
Does anyone know of another way to test for ordering?
assert page.body =~ /ITEM1.*ITEM2.*ITEM3/
– Uniflorous