spec: exempt pry from spec timeouts

Change-Id: I12c6360c72316e546f47589c28ce5e7cebf2172b
Reviewed-on: https://gerrit.instructure.com/100293
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
This commit is contained in:
Jon Jensen 2017-01-23 17:30:18 -07:00
parent 5b544a57cf
commit d415fe3109
2 changed files with 22 additions and 5 deletions

View File

@ -46,17 +46,14 @@ module WebMock::API
end
end
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
# nuke the db (say, if `rake db:migrate RAILS_ENV=test` created records),
# and then ensure people aren't creating records outside the rspec
# lifecycle, e.g. inside a describe/context block rather than a
# let/before/example
require_relative 'support/blank_slate_protection'
BlankSlateProtection.install!
require_relative 'support/discourage_slow_specs'
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActionView::TestCase::TestController.view_paths = ApplicationController.view_paths
# this makes sure that a broken transaction becomes functional again

View File

@ -0,0 +1,20 @@
# disable timeouts (in particular the spec one) once we start a pry session
#
# note: there's not really a great way to detect when the session is done,
# and making this only disable the spec timeout would be a lot more code.
# so once you start up pry, all timeouts are disabled, but ¯\_(ツ)_/¯
Timeout.singleton_class.prepend(Module.new {
def sleep(*)
result = super
in_debugger_land = defined?(Pry) && Pry::InputLock.input_locks.any?
if in_debugger_land
# abort the timeout thread, otherwise it will raise in the main
# thread once sleep returns
Thread.current.kill
end
result
end
})