From 7a8cd4cc2fe7c4dd13b5d10552f0edf5ccd3eb56 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Thu, 5 May 2011 10:30:43 -0400 Subject: [PATCH] Raise errors with the requested URL and not the last loaded URL --- spec/driver_spec.rb | 31 ++++++++++++++++++++++++++++--- src/WebPage.cpp | 2 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index 8d105cd..a88b4c5 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -546,17 +546,42 @@ describe Capybara::Driver::Webkit do end end + context "error app" do + before(:all) do + @app = lambda do |env| + if env['PATH_INFO'] == "/error" + body = "error" + [404, {}, []] + else + body = <<-HTML + +
+ + HTML + [200, + { 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s }, + [body]] + end + end + end + + it "raises a webkit error for the requested url" do + expect { + subject.find("//input").first.click + subject.find("//p") + }. + to raise_error(Capybara::Driver::Webkit::WebkitError, %r{/error}) + end + end + context "slow error app" do before(:all) do @app = lambda do |env| if env['PATH_INFO'] == "/error" - puts "time for an error" body = "error" sleep(1) - puts "done with error" [304, {}, []] else - puts "time for great success" body = <<-HTML
diff --git a/src/WebPage.cpp b/src/WebPage.cpp index 0a60166..6b1a138 100644 --- a/src/WebPage.cpp +++ b/src/WebPage.cpp @@ -87,6 +87,6 @@ bool WebPage::isLoading() const { } QString WebPage::failureString() { - return QString("Unable to load URL: ") + currentFrame()->url().toString(); + return QString("Unable to load URL: ") + currentFrame()->requestedUrl().toString(); }