Testing a list is sorted in the correct order capybara
You need to use the :nth-child
css selector.
Lets say your list of dates are in a <ul>
with the id #dates
, you could test order with:
page.should have_selector("ul#dates li:nth-child(1)", content: @date1.content)page.should have_selector("ul#dates li:nth-child(2)", content: @date2.content)
The first value passed into have_selector()
is your selector, the second (in this example) is the content you expect. You're not limited to passing just content for example if each date linked to the Date#show
action you could add url: date_path(@date)
.