Class: Totes::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/totes/reporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instObject



3
4
5
# File 'lib/totes/reporter.rb', line 3

def self.inst
  @inst ||= new
end

Instance Method Details

#failed(error) ⇒ Object



19
20
21
22
23
# File 'lib/totes/reporter.rb', line 19

def failed(error)
  @tests += 1
  @fails << error
  print "\e[31mF\e[0m"
end

#passed(query) ⇒ Object



14
15
16
17
# File 'lib/totes/reporter.rb', line 14

def passed(query)
  @tests += 1
  print "\e[32m.\e[0m"
end

#resetObject



7
8
9
10
11
12
# File 'lib/totes/reporter.rb', line 7

def reset
  @tests = 0
  @fails = []
  @time  = Time.new
  puts "Testing\n"
end

#summaryObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/totes/reporter.rb', line 25

def summary
  seconds = Time.new - @time
  prefix  = @fails.size == 0 ? "\e[32m✔︎ " : "\e[31m✖︎ "

  puts "\n\n#{prefix}Tests: %d, Failed: %d \e[0m\e[;2m(%.1f seconds, %.1f tests/sec)\e[0m\n" % [
    @tests, @fails.size, seconds, @tests / seconds
  ]

  print_failures
end