spec: output a decent backtrace when an after context block fails

Change-Id: If9924685d13198fd0cc1ce5b2613a30359bdbb52
Reviewed-on: https://gerrit.instructure.com/63272
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2015-10-29 14:40:30 -06:00
parent 39ef76a0f2
commit ced66d4c41
1 changed files with 20 additions and 0 deletions

View File

@ -58,6 +58,26 @@ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
ActionView::TestCase::TestController.view_paths = ApplicationController.view_paths
module RSpec::Core::Hooks
class AfterContextHook < Hook
def run(example)
exception_class = if defined?(RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue)
RSpec::Support::AllExceptionsExceptOnesWeMustNotRescue
else
Exception
end
example.instance_exec(example, &block)
rescue exception_class => e
# TODO: Come up with a better solution for this.
RSpec.configuration.reporter.message <<-EOS
An error occurred in an `after(:context)` hook.
#{e.class}: #{e.message}
occurred at #{e.backtrace.join("\n")}
EOS
end
end
end
unless CANVAS_RAILS3
Time.class_eval do
def compare_with_round(other)