├── CHANGELOG.rdoc ├── Manifest.txt ├── .autotest ├── Rakefile ├── test └── test_purdytest.rb ├── lib └── purdytest.rb └── README.rdoc /CHANGELOG.rdoc: -------------------------------------------------------------------------------- 1 | === 1.0.0 / 2011-06-02 2 | 3 | * 1 major enhancement 4 | 5 | * Birthday! 6 | 7 | -------------------------------------------------------------------------------- /Manifest.txt: -------------------------------------------------------------------------------- 1 | .autotest 2 | CHANGELOG.rdoc 3 | Manifest.txt 4 | README.rdoc 5 | Rakefile 6 | lib/purdytest.rb 7 | test/test_purdytest.rb 8 | -------------------------------------------------------------------------------- /.autotest: -------------------------------------------------------------------------------- 1 | # -*- ruby -*- 2 | 3 | require 'autotest/restart' 4 | 5 | Autotest.add_hook :initialize do |at| 6 | at.testlib = 'minitest/autorun' 7 | at.find_directories = ARGV unless ARGV.empty? 8 | end 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # -*- ruby -*- 2 | 3 | require 'rubygems' 4 | require 'hoe' 5 | 6 | Hoe.plugins.delete :rubyforge 7 | Hoe.plugin :minitest 8 | Hoe.plugin :gemspec # `gem install hoe-gemspec` 9 | Hoe.plugin :git # `gem install hoe-git` 10 | 11 | Hoe.spec 'purdytest' do 12 | developer('Aaron Patterson', 'aaron@tenderlovemaking.com') 13 | self.readme_file = 'README.rdoc' 14 | self.history_file = 'CHANGELOG.rdoc' 15 | self.extra_rdoc_files = FileList['*.rdoc'] 16 | self.extra_deps << ['minitest', '~> 5.5'] 17 | end 18 | 19 | # vim: syntax=ruby 20 | -------------------------------------------------------------------------------- /test/test_purdytest.rb: -------------------------------------------------------------------------------- 1 | require 'minitest/autorun' # from minitest 2 | require 'purdytest' 3 | 4 | Purdytest.configure do |io| 5 | io.pass = :blue 6 | io.fail = :green 7 | end 8 | 9 | describe 'my amazing test' do 10 | # generate many green dots! 11 | 50.times do |i| 12 | it "must #{i}" do 13 | 100.must_equal 100 14 | end 15 | end 16 | 17 | # generate some red Fs! 18 | 2.times do |i| 19 | it "compares #{i} to #{i + 1}" do 20 | i.must_equal i + 1 21 | end 22 | end 23 | 24 | it 'does stuff and shows a diff' do 25 | [1,2,3,4,5].must_equal %w{ a quick brown fox jumped over something! } 26 | end 27 | 28 | it 'does stuff and shows yellow' do 29 | skip "don't care!" 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /lib/purdytest.rb: -------------------------------------------------------------------------------- 1 | module Purdytest 2 | VERSION = '2.0.0' 3 | 4 | CONFIG = Struct.new(:pass, :fail, :error, :skip) 5 | .new(:green, :red, :red, :yellow) 6 | 7 | class IO < Struct.new :io 8 | # Colors stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm 9 | COLORS = { 10 | :black => 30, :on_black => 40, 11 | :red => 31, :on_red => 41, 12 | :green => 32, :on_green => 42, 13 | :yellow => 33, :on_yellow => 43, 14 | :blue => 34, :on_blue => 44, 15 | :magenta => 35, :on_magenta => 45, 16 | :cyan => 36, :on_cyan => 46, 17 | :white => 37, :on_white => 47 18 | } 19 | 20 | CONFIG.members.each { |m| define_method(m) { CONFIG[m] } } 21 | 22 | def print o 23 | case o 24 | when '.' then io.print "\e[#{COLORS[pass]}m.\e[0m" 25 | when 'E' then io.print "\e[#{COLORS[error]}mE\e[0m" 26 | when 'F' then io.print "\e[#{COLORS[self.fail]}mF\e[0m" 27 | when 'S' then io.print "\e[#{COLORS[skip]}mS\e[0m" 28 | else 29 | io.print o 30 | end 31 | end 32 | 33 | def method_missing msg, *args 34 | return super unless io.respond_to?(msg) 35 | io.send(msg, *args) 36 | end 37 | end 38 | 39 | ### 40 | # Yields the current color configuration 41 | def self.configure 42 | yield CONFIG 43 | end 44 | end 45 | 46 | module MiniTest 47 | def self.plugin_purdytest_init(options) 48 | composite = Minitest.reporter 49 | r = composite.reporters.find { |x| Minitest::ProgressReporter === x } 50 | r.io = Purdytest::IO.new r.io 51 | end 52 | extensions << "purdytest" 53 | end 54 | 55 | if system("colordiff", __FILE__, __FILE__) 56 | MiniTest::Assertions.diff = 'colordiff -u' 57 | end 58 | -------------------------------------------------------------------------------- /README.rdoc: -------------------------------------------------------------------------------- 1 | = purdytest 2 | 3 | * http://github.com/tenderlove/purdytest 4 | 5 | == DESCRIPTION: 6 | 7 | Purdytest extends minitest with pretty colors. Simply require minitest, then 8 | require purdytest, and you have colorific output on your terminal! 9 | 10 | For colorized diff output, make sure you have `colordiff` installed. 11 | 12 | == FEATURES/PROBLEMS: 13 | 14 | * It works! (I think) 15 | * If you want colored diffs, make sure you have 16 | [colordiff](http://colordiff.sourceforge.net/) installed. You can usually 17 | install colordiff via `brew install colordiff` or `port install colordiff`. 18 | 19 | * [HERE IS A VIDEO](http://www.youtube.com/watch?v=Md4PYx_Wj6M) 20 | 21 | == SYNOPSIS: 22 | 23 | require 'minitest/autorun' # from minitest 24 | require 'purdytest' 25 | 26 | describe 'my amazing test' do 27 | # generate many green dots! 28 | 50.times do |i| 29 | it "must #{i}" do 30 | 100.must_equal 100 31 | end 32 | end 33 | 34 | # generate some red Fs! 35 | 2.times do |i| 36 | it "compares #{i} to #{i + 1}" do 37 | i.must_equal i + 1 38 | end 39 | end 40 | 41 | it 'does stuff and shows a diff' do 42 | [1,2,3,4,5].must_equal %w{ a quick brown fox jumped over something! } 43 | end 44 | 45 | it 'does stuff and shows yellow' do 46 | skip "don't care!" 47 | end 48 | end 49 | 50 | Output color can be somewhat configured via +Purdytest.configure+: 51 | 52 | require 'minitest/autorun' # from minitest 53 | require 'purdytest' 54 | 55 | Purdytest.configure do |io| 56 | io.pass = :blue 57 | end 58 | 59 | describe 'my amazing test' do 60 | # generate many green dots! 61 | 50.times do |i| 62 | it "must #{i}" do 63 | 100.must_equal 100 64 | end 65 | end 66 | end 67 | 68 | For a list of possible configuration options, just check out the purdytest 69 | source code. 70 | 71 | == REQUIREMENTS: 72 | 73 | * minitest 74 | * [colordiff](http://colordiff.sourceforge.net/) 75 | 76 | == INSTALL: 77 | 78 | * gem install purdytest 79 | * brew install colordiff 80 | 81 | == LICENSE: 82 | 83 | (The MIT License) 84 | 85 | Copyright (c) 2011 Aaron Patterson 86 | 87 | Permission is hereby granted, free of charge, to any person obtaining 88 | a copy of this software and associated documentation files (the 89 | 'Software'), to deal in the Software without restriction, including 90 | without limitation the rights to use, copy, modify, merge, publish, 91 | distribute, sublicense, and/or sell copies of the Software, and to 92 | permit persons to whom the Software is furnished to do so, subject to 93 | the following conditions: 94 | 95 | The above copyright notice and this permission notice shall be 96 | included in all copies or substantial portions of the Software. 97 | 98 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 99 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 100 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 101 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 102 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 103 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 104 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 105 | --------------------------------------------------------------------------------