Capybara’s very good about waiting for AJAX. For example, this code
will keep checking the page for the element for Capybara.default_wait_time
seconds, allowing AJAX calls to finish:
expect(page).to have_css(‘.username’, text: ‘Gabe B-W’)
But there …
Read more at the source