mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
raise the exception rather than the exception class - Fix Issue #1785
This commit is contained in:
parent
374d113f41
commit
ab0d5f578a
4 changed files with 25 additions and 3 deletions
|
@ -9,4 +9,5 @@ gem 'xpath', :git => 'git://github.com/jnicklas/xpath.git'
|
||||||
gem 'term-ansicolor', '< 1.4.0'
|
gem 'term-ansicolor', '< 1.4.0'
|
||||||
gem 'tins', '< 1.7.0' # 1.7.0 requires ruby 2.0
|
gem 'tins', '< 1.7.0' # 1.7.0 requires ruby 2.0
|
||||||
|
|
||||||
gem 'selenium-webdriver', '< 3.0.0' # 3.0 requires ruby 2.0
|
gem 'selenium-webdriver', '< 3.0.0' # 3.0 requires ruby 2.0
|
||||||
|
gem 'addressable', '< 2.5.0' # 2.5 requires public_suffix which requires ruby 2.0
|
|
@ -125,7 +125,8 @@ module Capybara
|
||||||
begin
|
begin
|
||||||
raise CapybaraError, "Your application server raised an error - It has been raised in your test code because Capybara.raise_server_errors == true"
|
raise CapybaraError, "Your application server raised an error - It has been raised in your test code because Capybara.raise_server_errors == true"
|
||||||
rescue CapybaraError
|
rescue CapybaraError
|
||||||
raise @server.error.class, @server.error.message, @server.error.backtrace
|
#needed to get the cuase set correctly in JRuby -- otherwise we could just do raise @server.error
|
||||||
|
raise @server.error, @server.error.message, @server.error.backtrace
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
|
|
|
@ -428,6 +428,17 @@ Capybara::SpecHelper.spec "node" do
|
||||||
expect(e.cause.message).to match /Your application server raised an error/
|
expect(e.cause.message).to match /Your application server raised an error/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "sets an explanatory exception as the cause of server exceptions with errors with initializers", requires: [:server, :js], twtw: true do
|
||||||
|
skip "This version of ruby doesn't support exception causes" unless Exception.instance_methods.include? :cause
|
||||||
|
quietly { @session.visit("/other_error") }
|
||||||
|
expect do
|
||||||
|
@session.find(:css, 'span')
|
||||||
|
end.to raise_error(TestApp::TestAppOtherError) do |e|
|
||||||
|
expect(e.cause).to be_a Capybara::CapybaraError
|
||||||
|
expect(e.cause.message).to match /Your application server raised an error/
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def be_an_invalid_element_error(session)
|
def be_an_invalid_element_error(session)
|
||||||
|
|
|
@ -6,7 +6,12 @@ require 'yaml'
|
||||||
|
|
||||||
class TestApp < Sinatra::Base
|
class TestApp < Sinatra::Base
|
||||||
class TestAppError < StandardError; end
|
class TestAppError < StandardError; end
|
||||||
|
class TestAppOtherError < StandardError
|
||||||
|
def initialize(string1, msg)
|
||||||
|
@something = string1
|
||||||
|
@message = msg
|
||||||
|
end
|
||||||
|
end
|
||||||
set :root, File.dirname(__FILE__)
|
set :root, File.dirname(__FILE__)
|
||||||
set :static, true
|
set :static, true
|
||||||
set :raise_errors, true
|
set :raise_errors, true
|
||||||
|
@ -125,6 +130,10 @@ class TestApp < Sinatra::Base
|
||||||
raise TestAppError, "some error"
|
raise TestAppError, "some error"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get '/other_error' do
|
||||||
|
raise TestAppOtherError.new("something", "other error")
|
||||||
|
end
|
||||||
|
|
||||||
get '/load_error' do
|
get '/load_error' do
|
||||||
raise LoadError
|
raise LoadError
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue