require 'spec_helper' class SlowApp < TestApp get '/slow_page' do sleep 1 "

Loaded!

" end get '/really_slow_page' do sleep 5 end get '/slow_ajax_load' do <<-HTML with_js Click me HTML end end if $0 == __FILE__ if __FILE__ == $0 Rack::Handler::Mongrel.run SlowApp, :Port => 8070 end end describe Capybara::Session do context 'with akephalos driver' do before do @session = Capybara::Session.new(:akephalos, SlowApp) end context "slow page load" do it "should wait for the page to finish loading" do @session.visit('/slow_page') @session.current_url.should include('/slow_page') end end context "slow ajax load" do it "should wait for ajax to load" do @session.visit('/slow_ajax_load') @session.click_link('Click me') @session.should have_xpath("//p[contains(.,'Loaded!')]") end end end end