Module: Bacon::TestUnitOutput
- Defined in:
- lib/pretty_bacon/test_unit_output.rb
Overview
Overrides the TestUnitOutput to provide colored result output.
Instance Method Summary collapse
-
#handle_requirement(description, disabled = false) ⇒ Object
Represents the requirements as:.
-
#handle_specification(name) ⇒ Object
Represents the specifications as ‘:`.
- #handle_summary ⇒ Object
Instance Method Details
#handle_requirement(description, disabled = false) ⇒ Object
Represents the requirements as:
- .
-
successful
- E
-
error
- F
-
failure
- _
-
skipped
After the first failure or error all the other requirements are skipped.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pretty_bacon/test_unit_output.rb', line 27 def handle_requirement(description, disabled = false) if @skip_the_rest indicator = PrettyBacon.color(nil, '_') else error = yield if !error.empty? @skip_the_rest = true = error[0..0] color = ( == "E" ? :red : :yellow) indicator = PrettyBacon.color(color, ) = @last_spec_name = PrettyBacon.color(color, description) @failing_rquirement = "#{}: #{}" elsif disabled indicator = "D" else indicator = PrettyBacon.color(nil, '.') end end print indicator @indicators||='' @indicators << indicator end |
#handle_specification(name) ⇒ Object
Represents the specifications as ‘:`.
9 10 11 12 13 14 15 16 |
# File 'lib/pretty_bacon/test_unit_output.rb', line 9 def handle_specification(name) indicator = PrettyBacon.color(nil, ':') print indicator @indicators||='' @indicators << indicator @last_spec_name = name yield end |
#handle_summary ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pretty_bacon/test_unit_output.rb', line 51 def handle_summary puts "\n\n" puts @failing_rquirement first_error = '' error_count = 0 ErrorLog.lines.each do |s| error_count += 1 if s.include?('Error:') || s.include?('Informative') first_error << s if error_count <= 1 end first_error = first_error.gsub(Dir.pwd + '/', '') first_error = first_error.gsub(/lib\//, PrettyBacon.color(:yellow, 'lib') + '/') first_error = first_error.gsub(/:([0-9]+):/, ':' + PrettyBacon.color(:yellow, '\1') + ':') puts "\n#{first_error}" if Backtraces unless Counter[:disabled].zero? puts PrettyBacon.color(:yellow, "#{Counter[:disabled]} disabled specifications") end result = "%d specifications (%d requirements), %d failures, %d errors" % Counter.values_at(:specifications, :requirements, :failed, :errors) if Counter[:failed].zero? && Counter[:errors].zero? puts PrettyBacon.color(:green, result) else puts PrettyBacon.color(:red, result) end end |