Created
March 20, 2012 21:15
-
-
Save chrisbloom7/2141370 to your computer and use it in GitHub Desktop.
A cucumber/capybara step to test the order of elements in a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then /^I should see each item listed in alphabetical order in the items section$/ do | |
@items.each_with_index do |item, index| | |
find(:xpath, "//*[@id='items']/ul[@class='items']/li[#{index+1}]").inspect.should eq(find("li#item-#{item.friendly_id}").inspect) | |
@item = item | |
step "I should see the item listed in the items section" | |
end | |
end | |
Then /^I should( not)? see the item listed in the items section$/ do |negation| | |
assertion = negation ? :should_not : :should | |
selector = "a[href='#{item_path(@item)}']" | |
within(:css, "#items") do | |
page.send(assertion, have_selector(selector)) | |
if !negation | |
find(selector).should have_content(@item.name) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment