title: Waiting for redirect in Capybara Rails
body: <p>I am doing some integration tests on my website that is builtin Spree. I am using RSpec + Capybara in order to do these tests.</p>
  
  <p>I found that in the newer versions of Capybara, wait_until was removed from the source code because it is not necessary anymore to wait for an AJAX Request this way. Somehow, now Capybara is smart enough to wait for the AJAX Requests.</p>
  
  <p>What I am doing is quite simple:</p>
  
  <pre><code>visit product_path(product)
    within '.vip-buy-content' do
      first('.buy-button').click
    end
  expect(page.current_path).to eq(cart_path)
  </code></pre>
  
  <p>When the button is clicked, an AJAX request is done. When the AJAX request is done, a redirect happens.</p>
  
  <p>However, the expectation fails because it seems that Capybara will process this faster than the AJAX request and the redirect.</p>
  
  <p>If add a "sleep 10" above the expect, the spec will pass because it has enough time to process this.</p>
  
  <p>I would like a nicer way to wait for the redirect. Any ideas?.</p>