123456789_123456789_123456789_123456789_123456789_

Class: Minitest::PrideIO

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: lib/minitest/pride_plugin.rb

Overview

Show your testing pride!

Constant Summary

Class Attribute Summary

Class Method Summary

Instance Attribute Summary

  • #io readonly

    The IO we’re going to pipe through.

Instance Method Summary

Constructor Details

.new(io) ⇒ PrideIO

This method is for internal use only.
[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 48

def initialize io # :nodoc:
  @io = io
  # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
  # also reference http://en.wikipedia.org/wiki/ANSI_escape_code
  @colors ||= (31..36).to_a
  @size   = @colors.size
  @index  = 0
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(msg, *args)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 96

def method_missing msg, *args # :nodoc:
  io.send(msg, *args)
end

Class Attribute Details

.pride?Boolean (readonly)

Are we showing our testing pride?

[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 35

def self.pride?
  @pride ||= false
end

Class Method Details

.pride!

Activate the pride plugin. Called from both -p option and minitest/pride

[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 28

def self.pride!
  @pride = true
end

Instance Attribute Details

#io (readonly)

The IO we’re going to pipe through.

[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 46

attr_reader :io

Instance Method Details

#pride(string)

Color a string.

[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 89

def pride string
  string = "*" if string == "."
  c = @colors[@index % @size]
  @index += 1
  "#{ESC}#{c}m#{string}#{NND}"
end

#puts(*o)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/minitest/pride_plugin.rb', line 73

def puts *o # :nodoc:
  o.map! { |s|
    s.to_s.sub(/Finished/) {
      @index = 0
      "Fabulous run".split(//).map { |c|
        pride(c)
      }.join
    }
  }

  io.puts(*o)
end