Skip to content

Instantly share code, notes, and snippets.

@cs3b
Created October 24, 2011 17:14
Show Gist options
  • Save cs3b/1309547 to your computer and use it in GitHub Desktop.
Save cs3b/1309547 to your computer and use it in GitHub Desktop.
Patch for rspec runner - to handle firefox freezzing [ done in spirit of monkey see monkey path - use on your own risk :-)
module RSpec
module Core
class Example
def run(example_group_instance, reporter)
@example_group_instance = example_group_instance
@example_group_instance.example = self
start(reporter)
execution_attempt = 0
begin
unless pending
with_pending_capture do
with_around_hooks do
begin
run_before_each
@example_group_instance.instance_eval(&@example_block)
rescue Exception => e
execution_attempt += 1
if e.is_a?(Timeout::Error) and Capybara.current_driver == :selenium
Capybara.current_session.driver.browser.quit
Capybara.current_session.driver.instance_variable_set(:@browser, nil)
if execution_attempt < 2
redo
else
set_exception(e)
end
else
set_exception(e)
end
ensure
run_after_each
end
end
end
end
rescue Exception => e
set_exception(e)
ensure
@example_group_instance.example = nil
assign_auto_description
end
finish(reporter)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment