Skip to content

Instantly share code, notes, and snippets.

View ameuret's full-sized avatar

Arnaud Meuret ameuret

View GitHub Profile
@ameuret
ameuret / buying_steps.rb
Created February 6, 2014 21:40
How to help Capybara wait for a node to appear as a result of some asynchronous operation
include CapybaraAccessories
# This step occurs after an item was added to the cart through XHR
# It must wait for the call to return and for the UI to update.
# A badge must become visible and contain the number of items in cart.
# Without this kind of wait code Capybara's waiting features (2.2.1)
# still miss the update and fail the test.
Then(/^I see a caddie badge with (\d+) item\(s\)$/) do |count|
wait_for{page.find('#count')}.should have_content(count)