Class: Minitest::ProfileReporter
- Inherits:
-
AbstractReporter
- Object
- AbstractReporter
- Minitest::ProfileReporter
- Defined in:
- lib/minitest/profile_plugin.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#io ⇒ Object
Returns the value of attribute io.
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(options) ⇒ ProfileReporter
constructor
A new instance of ProfileReporter.
- #record(result) ⇒ Object
- #report ⇒ Object
- #sorted_results ⇒ Object
Constructor Details
#initialize(options) ⇒ ProfileReporter
Returns a new instance of ProfileReporter.
20 21 22 23 |
# File 'lib/minitest/profile_plugin.rb', line 20 def initialize() self.io = [:io] self.results = [] end |
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
18 19 20 |
# File 'lib/minitest/profile_plugin.rb', line 18 def io @io end |
#results ⇒ Object
Returns the value of attribute results.
18 19 20 |
# File 'lib/minitest/profile_plugin.rb', line 18 def results @results end |
Instance Method Details
#record(result) ⇒ Object
25 26 27 |
# File 'lib/minitest/profile_plugin.rb', line 25 def record(result) results << [result.time, result.location] end |
#report ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/minitest/profile_plugin.rb', line 29 def report return unless passed? puts puts "=" * 80 puts "Your 10 Slowest Tests" puts "=" * 80 puts sorted_results[0,10].each do |time, test_name| puts "#{sprintf("%7.4f",time)}ms - #{test_name}" end puts end |
#sorted_results ⇒ Object
43 44 45 |
# File 'lib/minitest/profile_plugin.rb', line 43 def sorted_results results.sort { |a, b| b[0] <=> a[0] } end |