def hook
assertion_error_class = self.assertion_error_class
test_case_class.class_eval do
include RR::DSL
include Mixin
if defined?(::ActiveSupport::TestCase)
is_active_support_test_case = lambda do |target|
target.is_a?(::ActiveSupport::TestCase)
end
else
is_active_support_test_case = lambda do |target|
false
end
end
unless instance_methods.any? { |method_name| method_name.to_sym == :setup_with_rr }
alias_method :setup_without_rr, :setup
define_method(:setup_with_rr) do
setup_without_rr
return if is_active_support_test_case.call(self)
RR.reset
RR.trim_backtrace = true
RR.overridden_error_class = assertion_error_class
end
alias_method :setup, :setup_with_rr
alias_method :teardown_without_rr, :teardown
define_method(:teardown_with_rr) do
begin
RR.verify unless is_active_support_test_case.call(self)
ensure
teardown_without_rr
end
end
alias_method :teardown, :teardown_with_rr
end
end
end