Class Test::Unit::UI::SpecDox::TestRunner
In: lib/test/spec/dox.rb
Parent: Test::Unit::UI::Console::TestRunner

Methods

Protected Instance methods

[Source]

    # File lib/test/spec/dox.rb, line 11
11:       def add_fault(fault)
12:         if fault.kind_of? Test::Spec::Disabled
13:           @disabled += 1
14:           output_no_nl " (disabled)"
15:         elsif fault.kind_of? Test::Spec::Empty
16:           @empty += 1
17:           output_no_nl " (empty)"
18:         else
19:           @faults << fault
20:           word = fault.class.name[/(.*::)?(.*)/, 2].upcase
21:           output_no_nl " (#{word} - #{@faults.size})"
22:         end
23:       end

[Source]

    # File lib/test/spec/dox.rb, line 34
34:       def finished(elapsed_time)
35:         nl
36:         output "Finished in #{elapsed_time} seconds."
37:         @faults.each_with_index do |fault, index|
38:           nl
39:           output("%3d) %s" % [index + 1, fault.long_display])
40:         end
41:         nl
42:         output_result
43:       end

[Source]

     # File lib/test/spec/dox.rb, line 138
138:       def indent(depth)
139:         @indent = depth
140:         @prefix = "  " * depth
141:       end

[Source]

     # File lib/test/spec/dox.rb, line 117
117:       def output_heading(heading)
118:         output "#{@prefix}#{heading}"
119:       end

[Source]

     # File lib/test/spec/dox.rb, line 113
113:       def output_item(item)
114:         output_no_nl "#{@prefix}- #{item}"
115:       end

[Source]

     # File lib/test/spec/dox.rb, line 108
108:       def output_no_nl(something, level=NORMAL)
109:         @io.write(something) if (output?(level))
110:         @io.flush
111:       end

[Source]

    # File lib/test/spec/dox.rb, line 45
45:       def output_result
46:         if @disabled > 0
47:           disabled = ", #{@disabled} disabled"
48:         else
49:           disabled = ""
50:         end
51: 
52:         if @empty > 0
53:           empty = ", #{@empty} empty"
54:         else
55:           empty = ""
56:         end
57: 
58:         r = ("%d specifications#{disabled}#{empty} " +
59:              "(%d requirements), %d failures") % [
60:                @result.run_count, @result.assertion_count, @result.failure_count]
61:         r << ", #{@result.error_count} errors"  if @result.error_count > 0
62:         output r
63:       end

[Source]

   # File lib/test/spec/dox.rb, line 7
7:       def setup_mediator
8:         @mediator = create_mediator(@suite)
9:       end

[Source]

     # File lib/test/spec/dox.rb, line 143
143:       def special_test?(name)
144:         name =~ /\Atest_spec \{.*?\} (-1 BEFORE|AFTER) ALL\(/
145:       end

[Source]

    # File lib/test/spec/dox.rb, line 25
25:       def started(result)
26:         @result = result
27:         @context = nil
28:         @contexts = []
29:         @disabled = 0
30:         @empty = 0
31:         indent 0
32:       end

[Source]

     # File lib/test/spec/dox.rb, line 96
 96:       def test_finished(name)
 97:         return  if special_test? name
 98: 
 99:         # Did any assertion run?
100:         if @assertions == @result.assertion_count && @prevdisabled == @disabled
101:           add_fault Test::Spec::Empty.new(@specname)
102:         end
103: 
104:         # Don't let empty contexts clutter up the output.
105:         nl  unless name =~ /\Adefault_test\(/
106:       end

[Source]

    # File lib/test/spec/dox.rb, line 65
65:       def test_started(name)
66:         return  if special_test? name
67: 
68:         contextname, @specname = unmangle name
69:         return  if contextname.nil? || @specname.nil?
70: 
71:         if @context != contextname
72:           @context = contextname
73: 
74:           @old_contexts = @contexts
75:           @contexts = @context.split("\t")
76: 
77:           common = 0
78:           @contexts.zip(@old_contexts) { |a, b|
79:             break  if a != b
80:             common += 1
81:           }
82: 
83:           nl  if common == 0
84: 
85:           @contexts[common..-1].each_with_index { |head, i|
86:             indent common + i
87:             output_heading head
88:           }
89:         end
90:         
91:         @assertions = @result.assertion_count
92:         @prevdisabled = @disabled
93:         output_item @specname
94:       end

[Source]

     # File lib/test/spec/dox.rb, line 121
121:       def unmangle(name)
122:         if name =~ /\Atest_spec \{(.*?)\} \d+ \[(.*)\]/
123:           contextname = $1
124:           specname = $2
125:         elsif name =~ /test_(.*?)\((.*)\)$/
126:           specname = $1
127:           contextname = $2
128: 
129:           contextname.gsub!(/^Test\B|\BTest$/, '')
130:           specname.gsub!(/_/, ' ')
131:         else
132:           contextname = specname = nil
133:         end
134: 
135:         [contextname, specname]
136:       end

[Validate]