Class: Test::Unit::UI::SpecDox::TestRunner

### Home Classes Methods

### In Files

- lib/test/spec/dox.rb

### Parent

Test::Unit::UI::Console::TestRunner

### Methods

- #add_fault
- #finished
- #indent
- #output_heading
- #output_item
- #output_no_nl
- #output_result
- #setup_mediator
- #special_test?
- #started
- #test_finished
- #test_started
- #unmangle

### Files

- README
- ROADMAP
- SPECS

### Class/Module Index

Quicksearch

- Test
- Test::Spec
- Test::Spec::CustomShould
- Test::Spec::DefinitionError
- Test::Spec::Should
- Test::Spec::ShouldNot
- Test::Spec::TestCase
- Test::Spec::TestCase::ClassMethods
- Test::Spec::TestCase::InstanceMethods
- Test::Unit
- Test::Unit::UI
- Test::Unit::UI::RDox
- Test::Unit::UI::RDox::TestRunner
- Test::Unit::UI::SpecDox
- Test::Unit::UI::SpecDox::TestRunner
- Object

No matching classes.

# Test::Unit::UI::SpecDox::TestRunner

### Protected Instance Methods

add_fault(fault) click to toggle source

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

finished(elapsed_time) click to toggle source

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

indent(depth) click to toggle source

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

output_heading(heading) click to toggle source

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

output_item(item) click to toggle source

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

output_no_nl(something, level=NORMAL) click to toggle source

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

output_result() click to toggle source

    # File lib/test/spec/dox.rb, line 46
    def output_result
      if @disabled > 0
        disabled = ", #{@disabled} disabled"
      else
        disabled = ""
      end

      if @empty > 0
        empty = ", #{@empty} empty"
      else
        empty = ""
      end

      r = ("%d specifications#{disabled}#{empty} " +
           "(%d requirements), %d failures") % [
             @result.run_count, @result.assertion_count, @result.failure_count]
      r << ", #{@result.error_count} errors"  if @result.error_count > 0
      output r
    end

setup_mediator() click to toggle source

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

special_test?(name) click to toggle source

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

started(result) click to toggle source

    # File lib/test/spec/dox.rb, line 25
    def started(result)
      @io ||= @output
      @result = result
      @context = nil
      @contexts = []
      @disabled = 0
      @empty = 0
      indent 0
    end

test_finished(name) click to toggle source

    # File lib/test/spec/dox.rb, line 97
    def test_finished(name)
      return  if special_test? name

      # Did any assertion run?
      if @assertions == @result.assertion_count && @prevdisabled == @disabled
        add_fault Test::Spec::Empty.new(@specname)
      end

      # Don't let empty contexts clutter up the output.
      nl  unless name =~ /\Adefault_test\(/
    end

test_started(name) click to toggle source

    # File lib/test/spec/dox.rb, line 66
    def test_started(name)
      return  if special_test? name

      contextname, @specname = unmangle name
      return  if contextname.nil? || @specname.nil?

      if @context != contextname
        @context = contextname

        @old_contexts = @contexts
        @contexts = @context.split("\t")

        common = 0
        @contexts.zip(@old_contexts) { |a, b|
          break  if a != b
          common += 1
        }

        nl  if common == 0

        @contexts[common..-1].each_with_index { |head, i|
          indent common + i
          output_heading head
        }
      end

      @assertions = @result.assertion_count
      @prevdisabled = @disabled
      output_item @specname
    end

unmangle(name) click to toggle source

    # File lib/test/spec/dox.rb, line 122
    def unmangle(name)
      if name =~ /\Atest_spec \{(.*?)\} \d+ \[(.*)\]/
        contextname = $1
        specname = $2
      elsif name =~ /test_(.*?)\((.*)\)$/
        specname = $1
        contextname = $2

        contextname.gsub!(/^Test\B|\BTest$/, '')
        specname.gsub!(/_/, ' ')
      else
        contextname = specname = nil
      end

      [contextname, specname]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.