Fixed Spec in Test Unit more thoroghly
This commit is contained in:
parent
dd8688f371
commit
6bfdcc54cc
|
@ -152,7 +152,9 @@ module Webrat
|
|||
begin
|
||||
value = yield
|
||||
rescue Exception => e
|
||||
raise e unless yieldable_exceptions.include?(e.class)
|
||||
unless is_ignorable_wait_for_exception?(e)
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
return value if value
|
||||
|
@ -187,14 +189,13 @@ module Webrat
|
|||
|
||||
end
|
||||
|
||||
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)
|
||||
def is_ignorable_wait_for_exception?(exception) #:nodoc:
|
||||
if defined?(::Spec::Expectations::ExpectationNotMetError)
|
||||
return true if exception.class == ::Spec::Expectations::ExpectationNotMetError
|
||||
end
|
||||
return true if [::Selenium::CommandError, Webrat::WebratError].include?(exception.class)
|
||||
return false
|
||||
end
|
||||
|
||||
def setup #:nodoc:
|
||||
|
|
|
@ -10,19 +10,9 @@ describe Webrat::SeleniumSession do
|
|||
@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 throw timeout instead of spec expectionnotmet error" do
|
||||
lambda {
|
||||
@selenium.wait_for(:timeout => 0.1) do
|
||||
@selenium.wait_for(:timeout => 0.0001) do
|
||||
raise ::Spec::Expectations::ExpectationNotMetError
|
||||
end
|
||||
}.should raise_error(Webrat::TimeoutError)
|
||||
|
@ -30,7 +20,7 @@ describe Webrat::SeleniumSession do
|
|||
|
||||
it "should throw timeout instead of selenium command error" do
|
||||
lambda {
|
||||
@selenium.wait_for(:timeout => 0.1) do
|
||||
@selenium.wait_for(:timeout => 0.0001) do
|
||||
raise ::Selenium::CommandError
|
||||
end
|
||||
}.should raise_error(Webrat::TimeoutError)
|
||||
|
@ -38,7 +28,7 @@ describe Webrat::SeleniumSession do
|
|||
|
||||
it "should throw timeout instead of webrat error" do
|
||||
lambda {
|
||||
@selenium.wait_for(:timeout => 0.1) do
|
||||
@selenium.wait_for(:timeout => 0.0001) do
|
||||
raise Webrat::WebratError.new
|
||||
end
|
||||
}.should raise_error(Webrat::TimeoutError)
|
||||
|
|
Loading…
Reference in New Issue