Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise server errors on visit and synchronize

This should hopefully make them appear earlier and be more helpful.
  • Loading branch information...
commit a94dfbc4d07dcfe53bbea334f7f47f584737a0c0 1 parent 595cd4a
@jnicklas authored
View
1  lib/capybara/node/base.rb
@@ -80,6 +80,7 @@ def synchronize(seconds=Capybara.default_wait_time)
begin
yield
rescue => e
+ session.raise_server_error!
raise e unless driver.wait?
raise e unless catch_error?(e)
raise e if (Time.now - start_time) >= seconds
View
14 lib/capybara/session.rb
@@ -81,12 +81,20 @@ def reset!
assert_no_selector :xpath, "/html/body/*"
@touched = false
end
+ raise_server_error!
+ end
+ alias_method :cleanup!, :reset!
+ alias_method :reset_session!, :reset!
+
+ ##
+ #
+ # Raise errors encountered in the server
+ #
+ def raise_server_error!
raise @server.error if Capybara.raise_server_errors and @server and @server.error
ensure
@server.reset_error! if @server
end
- alias_method :cleanup!, :reset!
- alias_method :reset_session!, :reset!
##
#
@@ -179,6 +187,8 @@ def title
# @param [String] url The URL to navigate to
#
def visit(url)
+ raise_server_error!
+
@touched = true
if url !~ /^http/ and Capybara.app_host
View
7 lib/capybara/spec/session/click_link_spec.rb
@@ -14,6 +14,13 @@
@session.should have_content('Another World')
end
+ it "raises any errors caught inside the server", :requires => [:server] do
+ quietly { @session.visit("/error") }
+ expect do
+ @session.click_link('foo')
+ end.to raise_error(TestApp::TestAppError)
+ end
+
context "with id given" do
it "should take user to the linked page" do
@session.click_link('foo')
View
7 lib/capybara/spec/session/visit_spec.rb
@@ -26,6 +26,13 @@
@session.should have_content('Hello world!')
end
+ it "raises any errors caught inside the server", :requires => [:server] do
+ quietly { @session.visit("/error") }
+ expect do
+ @session.visit("/")
+ end.to raise_error(TestApp::TestAppError)
+ end
+
context "when Capybara.always_include_port is true" do
let(:root_uri) do

0 comments on commit a94dfbc

Please sign in to comment.
Something went wrong with that request. Please try again.