require 'spec_helper' require 'capybara-webkit' describe Capybara::Session do subject { Capybara::Session.new(:reusable_webkit, @app) } after { subject.reset! } context "slow javascript app" do before(:all) do @app = lambda do |env| body = <<-HTML

Hello

HTML [200, { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, [body]] end end before do @default_wait_time = Capybara.default_wait_time Capybara.default_wait_time = 1 end after { Capybara.default_wait_time = @default_wait_time } it "waits for a request to load" do subject.visit("/") subject.find_button("Submit").click subject.should have_content("Goodbye"); end end context "simple app" do before(:all) do @app = lambda do |env| body = <<-HTML Hello HTML [200, { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, [body]] end end it "inspects nodes" do subject.visit("/") subject.all(:xpath, "//strong").first.inspect.should include("strong") end end end describe Capybara::Session, "with TestApp" do before do @session = Capybara::Session.new(:reusable_webkit, TestApp) end # it_should_behave_like "session" # it_should_behave_like "session with javascript support" end