Class: Minitest::SnailReporter
- Inherits:
-
Reporter
- Object
- Reporter
- Minitest::SnailReporter
- Defined in:
- lib/minitest/snail_reporter.rb
Instance Attribute Summary collapse
-
#max_duration ⇒ Object
readonly
Returns the value of attribute max_duration.
-
#slow_tests ⇒ Object
readonly
Returns the value of attribute slow_tests.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(io = STDOUT, options = self.class.options) ⇒ SnailReporter
constructor
A new instance of SnailReporter.
- #record(result) ⇒ Object
- #report ⇒ Object
Constructor Details
#initialize(io = STDOUT, options = self.class.options) ⇒ SnailReporter
Returns a new instance of SnailReporter.
20 21 22 23 24 25 |
# File 'lib/minitest/snail_reporter.rb', line 20 def initialize(io = STDOUT, = self.class.) super @max_duration = .fetch(:max_duration) @slow_tests = [] end |
Instance Attribute Details
#max_duration ⇒ Object (readonly)
Returns the value of attribute max_duration.
3 4 5 |
# File 'lib/minitest/snail_reporter.rb', line 3 def max_duration @max_duration end |
#slow_tests ⇒ Object (readonly)
Returns the value of attribute slow_tests.
3 4 5 |
# File 'lib/minitest/snail_reporter.rb', line 3 def slow_tests @slow_tests end |
Class Method Details
.enable!(options = {}) ⇒ Object
11 12 13 14 |
# File 'lib/minitest/snail_reporter.rb', line 11 def self.enable!( = {}) @enabled = true self..merge!() end |
.enabled? ⇒ Boolean
16 17 18 |
# File 'lib/minitest/snail_reporter.rb', line 16 def self.enabled? @enabled ||= false end |
.options ⇒ Object
5 6 7 8 9 |
# File 'lib/minitest/snail_reporter.rb', line 5 def self. @default_options ||= { :max_duration => 2 } end |
Instance Method Details
#record(result) ⇒ Object
27 28 29 |
# File 'lib/minitest/snail_reporter.rb', line 27 def record result slow_tests << result if result.time > max_duration end |
#report ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/minitest/snail_reporter.rb', line 31 def report return if slow_tests.empty? slow_tests.sort_by!{|r| -r.time} io.puts io.puts "#{slow_tests.length} slow tests." slow_tests.each_with_index do |result, i| io.puts "%3d) %s: %.2f s" % [i+1, result.location, result.time] end end |