catches spec failed exception again
This commit is contained in:
parent
abac2023bc
commit
977f643dca
@ -150,8 +150,8 @@ module Webrat
|
||||
|
||||
begin
|
||||
value = yield
|
||||
rescue ::Selenium::CommandError, Webrat::WebratError
|
||||
value = nil
|
||||
rescue Exception => e
|
||||
raise e unless yieldable_exceptions.include?(e.class)
|
||||
end
|
||||
|
||||
return value if value
|
||||
@ -182,10 +182,19 @@ module Webrat
|
||||
else
|
||||
$browser.capture_screenshot(filename)
|
||||
end
|
||||
open_in_browser(filename)
|
||||
open_in_browser(filename)
|
||||
|
||||
end
|
||||
|
||||
protected
|
||||
def yieldable_exceptions
|
||||
return [::Selenium::CommandError, Webrat::WebratError] unless lib_defined?(::Spec::Expectations::ExpectationNotMetError)
|
||||
[::Spec::Expectations::ExpectationNotMetError, ::Selenium::CommandError, Webrat::WebratError]
|
||||
end
|
||||
|
||||
protected
|
||||
def lib_defined?(library)
|
||||
defined?(library)
|
||||
end
|
||||
|
||||
def setup #:nodoc:
|
||||
Webrat::Selenium::SeleniumRCServer.boot
|
||||
@ -202,7 +211,7 @@ module Webrat
|
||||
|
||||
def create_browser
|
||||
$browser = ::Selenium::Client::Driver.new(Webrat.configuration.selenium_server_address || "localhost",
|
||||
Webrat.configuration.selenium_server_port, Webrat.configuration.selenium_browser_key, "http://#{Webrat.configuration.application_address}:#{Webrat.configuration.application_port}")
|
||||
Webrat.configuration.selenium_server_port, Webrat.configuration.selenium_browser_key, "http://#{Webrat.configuration.application_address}:#{Webrat.configuration.application_port}")
|
||||
$browser.set_speed(0) unless Webrat.configuration.selenium_server_address
|
||||
|
||||
at_exit do
|
||||
|
33
spec/public/selenium/selenium_session_spec.rb
Normal file
33
spec/public/selenium/selenium_session_spec.rb
Normal file
@ -0,0 +1,33 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
require "webrat/selenium/silence_stream"
|
||||
require "webrat/selenium/selenium_session"
|
||||
|
||||
describe Webrat::SeleniumSession do
|
||||
|
||||
before :each do
|
||||
Webrat.configuration.mode = :selenium
|
||||
@selenium = Webrat::SeleniumSession.new()
|
||||
end
|
||||
|
||||
it "should provide a list yieldable exceptions without spec if spec isn't defined" do
|
||||
@selenium.should_receive(:lib_defined?).with(::Spec::Expectations::ExpectationNotMetError).and_return(false)
|
||||
@selenium.yieldable_exceptions.should == [::Selenium::CommandError, Webrat::WebratError]
|
||||
end
|
||||
|
||||
it "should provide a list yieldable exceptions with rspec" do
|
||||
@selenium.should_receive(:lib_defined?).with(::Spec::Expectations::ExpectationNotMetError).and_return(true)
|
||||
@selenium.yieldable_exceptions.should == [::Spec::Expectations::ExpectationNotMetError, ::Selenium::CommandError, Webrat::WebratError]
|
||||
end
|
||||
|
||||
it "should handle yieldable exceptions in the wait_for" do
|
||||
begin
|
||||
@selenium.wait_for(:timeout => 0.25) do
|
||||
raise Webrat::WebratError.new
|
||||
end
|
||||
fail("didn't throw")
|
||||
rescue Webrat::TimeoutError
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user