Module: TopTests

Defined in:
lib/top_tests.rb,
lib/top_tests/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
'0.1.1'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Class methods ###



9
10
11
12
13
14
15
16
# File 'lib/top_tests.rb', line 9

def self.included(klass)
  klass.extend(ClassMethods)
  if Minitest.respond_to?(:after_run)
    Minitest.after_run { klass.after_all_tests }
  else
    MiniTest::Unit.after_tests { klass.after_all_tests }  # Deprecated
  end
end

Instance Method Details

#after_teardownObject



27
28
29
30
31
32
33
34
# File 'lib/top_tests.rb', line 27

def after_teardown
  super
  if @timer_started_at # Unset when a setup hook fails before top test.
    # Instance variable @__name__ is used prior to minitest 5.
    test_name = "#{self.class}##{@__name__ || name}"
    self.class.tests_durations << [test_name, Time.now - @timer_started_at]
  end
end

#before_setupObject

Instance methods ###



22
23
24
25
# File 'lib/top_tests.rb', line 22

def before_setup
  super
  @timer_started_at = Time.now
end