Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sobrinho committed Jun 24, 2011
0 parents commit ca7f1cc
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.gem
.bundle
Gemfile.lock
pkg/*
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in minitest-colorize.gemspec
gemspec
9 changes: 9 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'bundler/gem_tasks'
require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/*_test.rb'
end

task :default => :test
1 change: 1 addition & 0 deletions lib/minitest-colorize.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'minitest/colorize'
33 changes: 33 additions & 0 deletions lib/minitest/colorize.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "minitest/colorize/version"

module MiniTest
class Colorize
attr_accessor :io

def initialize(io)
self.io = io
end

def print(out)
if color = colors[out]
io.print "#{color}#{out}#{clear}"
else
io.print out
end
end

def colors
{ "F" => "\e[31m", "E" => "\e[31m", "S" => "\e[33m", "." => "\e[32m" }
end

def clear
"\e[0m"
end

def method_missing(method, *args, &block)
io.send(method, *args, &block)
end
end
end

MiniTest::Unit.output = MiniTest::Colorize.new(MiniTest::Unit.output)
5 changes: 5 additions & 0 deletions lib/minitest/colorize/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module MiniTest
class Colorize
VERSION = "0.0.1"
end
end
21 changes: 21 additions & 0 deletions minitest-colorize.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "minitest/colorize/version"

Gem::Specification.new do |s|
s.name = "minitest-colorize"
s.version = MiniTest::Colorize::VERSION
s.authors = ["Gabriel Sobrinho"]
s.email = ["gabriel.sobrinho@gmail.com"]
s.homepage = ""
s.summary = %q{Colorize minitest output}
s.description = %q{Colorize minitest output}

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency 'minitest', '~> 2.0'
s.add_development_dependency 'rake', '>= 0.8.7'
end
38 changes: 38 additions & 0 deletions test/minitest_colorize_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'test_helper'

class MiniTest::ColorizeTest < MiniTest::Unit::TestCase
def test_fail
assert_output "\e[31mF\e[0m" do
colorize = MiniTest::Colorize.new($stdout)
colorize.print 'F'
end
end

def test_error
assert_output "\e[31mE\e[0m" do
colorize = MiniTest::Colorize.new($stdout)
colorize.print 'E'
end
end

def test_skip
assert_output "\e[33mS\e[0m" do
colorize = MiniTest::Colorize.new($stdout)
colorize.print 'S'
end
end

def test_success
assert_output "\e[32m.\e[0m" do
colorize = MiniTest::Colorize.new($stdout)
colorize.print '.'
end
end

def test_others
assert_output "colorize" do
colorize = MiniTest::Colorize.new($stdout)
colorize.print 'colorize'
end
end
end
4 changes: 4 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'rubygems'
require 'bundler/setup'
require 'minitest/autorun'
require 'minitest-colorize'

0 comments on commit ca7f1cc

Please sign in to comment.