Skip to content

Commit

Permalink
make it work with minitest 5
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jan 24, 2015
1 parent a8a4754 commit deba64e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
3 changes: 1 addition & 2 deletions Rakefile
Expand Up @@ -13,8 +13,7 @@ Hoe.spec 'purdytest' do
self.readme_file = 'README.rdoc'
self.history_file = 'CHANGELOG.rdoc'
self.extra_rdoc_files = FileList['*.rdoc']
self.extra_deps << ['minitest', '~> 2.2']
self.testlib = :minitest
self.extra_deps << ['minitest', '~> 5.5']
end

# vim: syntax=ruby
34 changes: 17 additions & 17 deletions lib/purdytest.rb
@@ -1,12 +1,12 @@
module Purdytest
VERSION = '1.0.0'
VERSION = '2.0.0'

class IO
attr_reader :io
attr_accessor :pass, :fail, :skip, :error
CONFIG = Struct.new(:pass, :fail, :error, :skip)
.new(:green, :red, :red, :yellow)

# Colors stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
COLORS = {
class IO < Struct.new :io
# Colors stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
COLORS = {
:black => 30, :on_black => 40,
:red => 31, :on_red => 41,
:green => 32, :on_green => 42,
Expand All @@ -17,13 +17,7 @@ class IO
:white => 37, :on_white => 47
}

def initialize io
@io = io
@pass = :green
@fail = :red
@error = :red
@skip = :yellow
end
CONFIG.members.each { |m| define_method(m) { CONFIG[m] } }

def print o
case o
Expand All @@ -43,14 +37,20 @@ def method_missing msg, *args
end

###
# Yields the current minitest output, which *should* be an instance
# of Purdytest::IO (hopefully).
# Yields the current color configuration
def self.configure
yield MiniTest::Unit.output
yield CONFIG
end
end

MiniTest::Unit.output = Purdytest::IO.new(MiniTest::Unit.output)
module MiniTest
def self.plugin_purdytest_init(options)
composite = Minitest.reporter
r = composite.reporters.find { |x| Minitest::ProgressReporter === x }
r.io = Purdytest::IO.new r.io
end
extensions << "purdytest"
end

if system("colordiff", __FILE__, __FILE__)
MiniTest::Assertions.diff = 'colordiff -u'
Expand Down

0 comments on commit deba64e

Please sign in to comment.