Class: HotOrNot::TestUnitAnnouncer

Inherits:
Object
  • Object
show all
Includes:
Announcer
Defined in:
lib/hot_or_not/announcers/test_unit_announcer.rb

Instance Method Summary collapse

Constructor Details

#initialize(output_dir) ⇒ TestUnitAnnouncer

Returns a new instance of TestUnitAnnouncer.



5
6
7
8
9
# File 'lib/hot_or_not/announcers/test_unit_announcer.rb', line 5

def initialize(output_dir)
  @output_dir = output_dir
  @start, @results = nil, []
  @output_count = 0
end

Instance Method Details

#announce_error(result) ⇒ Object



41
42
43
44
# File 'lib/hot_or_not/announcers/test_unit_announcer.rb', line 41

def announce_error(result)
  @results << { :status => :error, :result => result }
  print "E"
end

#announce_failure(result) ⇒ Object



36
37
38
39
# File 'lib/hot_or_not/announcers/test_unit_announcer.rb', line 36

def announce_failure(result)
  @results << { :status => :failure, :result => result }
  print "N"
end

#announce_success(result) ⇒ Object



31
32
33
34
# File 'lib/hot_or_not/announcers/test_unit_announcer.rb', line 31

def announce_success(result)
  @results << { :status => :success, :result => result }
  print "."
end

#endingObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hot_or_not/announcers/test_unit_announcer.rb', line 16

def ending
  completion_time = Time.now - @start
  counts = Hash.new(0)
  puts
  @results.each do |result_hash|
    status = result_hash[:status]
    send :"output_#{status}", result_hash
    counts[status] += 1
  end

  puts "Finished in %.6f seconds." % [completion_time]
  puts
  puts "#{@results.count} body comparisons, #{counts[:success]} hot bodies, #{counts[:failure]} not-hot bodies, #{counts[:error]} errored bodies"
end

#startingObject



11
12
13
14
# File 'lib/hot_or_not/announcers/test_unit_announcer.rb', line 11

def starting
  puts "Starting to compare the bodies"
  @start = Time.now
end