Skip to content

Commit

Permalink
Add config option which disabled server errors being raise, closes te…
Browse files Browse the repository at this point in the history
  • Loading branch information
jnicklas committed Feb 16, 2013
1 parent a1c8453 commit e22c937
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class << self
attr_accessor :asset_root, :app_host, :run_server, :default_host, :always_include_port
attr_accessor :server_host, :server_port, :exact, :match, :exact_options
attr_accessor :default_selector, :default_wait_time, :ignore_hidden_elements
attr_accessor :save_and_open_page_path, :automatic_reload
attr_accessor :save_and_open_page_path, :automatic_reload, :raise_server_errors
attr_writer :default_driver, :current_driver, :javascript_driver, :session_name
attr_accessor :app

Expand Down Expand Up @@ -346,6 +346,7 @@ module Selenium
config.automatic_reload = true
config.match = :smart
config.exact = false
config.raise_server_errors = true
end

Capybara.register_driver :rack_test do |app|
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def driver
def reset!
driver.reset! if @touched
@touched = false
raise @server.error if @server and @server.error
raise @server.error if Capybara.raise_server_errors and @server and @server.error
ensure
@server.reset_error! if @server
end
Expand Down
12 changes: 10 additions & 2 deletions lib/capybara/spec/session/reset_session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@
@session.should have_no_selector('.//h1')
end

it "raises any errors caught inside the server" do
it "raises any errors caught inside the server", :requires => [:server] do
quietly { @session.visit("/error") }
expect do
quietly { @session.visit("/error") }
@session.reset_session!
end.to raise_error(TestApp::TestAppError)
@session.visit("/")
@session.current_path.should == "/"
end

it "ignores server errors when `Capybara.raise_server_errors = false`", :requires => [:server] do
Capybara.raise_server_errors = false
quietly { @session.visit("/error") }
@session.reset_session!
@session.visit("/")
@session.current_path.should == "/"
end
end
1 change: 1 addition & 0 deletions lib/capybara/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def reset!
Capybara.ignore_hidden_elements = true
Capybara.exact = false
Capybara.exact_options = false
Capybara.raise_server_errors = true
Capybara.match = :smart
end

Expand Down

0 comments on commit e22c937

Please sign in to comment.