Module: Bacon::SpecDoxOutput

Defined in:
lib/Bacon_Colored.rb

Instance Method Summary collapse

Instance Method Details

#handle_requirement(description) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/Bacon_Colored.rb', line 13

def handle_requirement(description)
  error = yield
  color = case error
          when 'FAILED'
            :red
          else
            :yellow
          end

  mark = error.empty? ? "".green : "".send(color)
  print " #{mark}#{description}"

  return puts("") if error.empty?
  puts " [#{error}]".send(color)
end

#handle_summaryObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/Bacon_Colored.rb', line 29

def handle_summary
  specs, reqs, fails, errs = Counter.values_at(:specifications, :requirements, :failed, :errors)
  all_pass = reqs > 1 && (fails == errs) && (errs == 0)
  single_pass = reqs == 1 && specs == 1 && (errs == 0) && (fails == errs)

  print ErrorLog  if Backtraces

  print "%d specifications (%d requirements)".send(all_pass ? :green : :to_s ) % [ specs, reqs ]

  if single_pass
    print( ". Just one requirement and it passes. ".green )
  elsif  all_pass
    print( ". All pass. ".green )
  else
    print ", "
    print "#{fails} failures".send( fails > 0 ? :red : :to_s )
    print ", "
    print "#{errs} errors".send( errs > 0 ? :yellow : :to_s )
    print ". "
  end

  puts
  puts
end