lib/calabash-cucumber/wait_helpers.rb in calabash-cucumber-0.14.2.pre1 vs lib/calabash-cucumber/wait_helpers.rb in calabash-cucumber-0.14.2
- old
+ new
@@ -110,11 +110,11 @@
sleep(retry_frequency)
return screenshot_and_retry(msg, &block)
else
raise wait_error(msg)
end
- rescue Exception => e
+ rescue => e
handle_error_with_options(e, nil, screenshot_on_error)
end
end
# Repeatedly runs an action (for side-effects) until a condition is satisfied.
@@ -210,20 +210,21 @@
# @param [String] element_query a Calabash query to be empty (i.e. `element_does_not_exist(element_query)`)
# @param [Hash] options options for controlling the details of the wait.
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
# @return [nil] when the condition is satisfied
# @raise [Calabash::Cucumber::WaitHelpers::WaitError] when the timeout is exceeded
- def wait_for_element_does_not_exists(element_query, options={})
+ def wait_for_element_does_not_exist(element_query, options={})
options[:timeout_message] = options[:timeout_message] || "Timeout waiting for element to not exist: #{element_query}"
wait_for(options) { element_does_not_exist(element_query) }
end
+ alias_method :wait_for_element_does_not_exists, :wait_for_element_does_not_exist
# Waits for one or more Calabash queries to all return empty results (typically a UI elements to disappear).
# Uses `wait_for`.
# @see #wait_for
# @see #wait_for_element_exists
- # @see #wait_for_element_does_not_exists
+ # @see #wait_for_element_does_not_exist
# @see Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS
#
# @param [Array<String>] elements_arr an Array of Calabash queries to be empty (i.e. `element_does_not_exist(element_query)`)
# @param [Hash] options options for controlling the details of the wait.
# The same options as {Calabash::Cucumber::WaitHelpers::DEFAULT_OPTS} apply.
@@ -286,12 +287,12 @@
res['outcome'] == 'SUCCESS'
end
else
raise wait_error(msg)
end
- rescue Exception => e
- handle_error_with_options(e,nil, screenshot_on_error)
+ rescue => e
+ handle_error_with_options(e, nil, screenshot_on_error)
end
end
# Waits for all elements to stop animating (EXPERIMENTAL).
# @param [Hash] options options for controlling the details of the wait.
@@ -404,26 +405,29 @@
raise wait_error(msg)
end
end
# @!visibility private
- # raises an error by raising a exception and conditionally takes a
- # screenshot based on the value of +screenshot_on_error+.
- # @param [Exception,nil] ex an exception to raise
+ # Raises an error by raising a error and conditionally takes a screenshot
+ # based on the value of +screenshot_on_error+.
+ # @param [RuntimeError,nil] error an error to raise
# @param [String,nil] timeout_message the message of the raise
# @param [Boolean] screenshot_on_error if true takes a screenshot before
# raising an error
# @return [nil]
- # @raise RuntimeError based on +ex+ and +timeout_message+
- def handle_error_with_options(ex, timeout_message, screenshot_on_error)
- msg = (timeout_message || ex)
- if ex
- msg = "#{msg} (#{ex.class})"
+ # @raise [StandardError] If `error`, then that kind of error is raised.
+ # Otherwise raise a RuntimeError.
+ def handle_error_with_options(error, timeout_message, screenshot_on_error)
+ msg = (timeout_message || error)
+ if error
+ error_class = error.class
+ else
+ error_class = RuntimeError
end
if screenshot_on_error
screenshot_and_raise msg
else
- raise msg
+ raise error_class, msg
end
end
# @private
# if +msg+ is a String, a new WaitError is returned. Otherwise +msg+