purdytest 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,8 @@
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
data/.gemtest ADDED
File without changes
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2011-06-02
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ .autotest
2
+ CHANGELOG.rdoc
3
+ Manifest.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/purdytest.rb
7
+ test/test_purdytest.rb
data/README.rdoc ADDED
@@ -0,0 +1,104 @@
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.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
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', '~> 2.2']
17
+ self.testlib = :minitest
18
+ end
19
+
20
+ # vim: syntax=ruby
data/lib/purdytest.rb ADDED
@@ -0,0 +1,57 @@
1
+ module Purdytest
2
+ VERSION = '1.0.0'
3
+
4
+ class IO
5
+ attr_reader :io
6
+ attr_accessor :pass, :fail, :skip, :error
7
+
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
+ def initialize io
21
+ @io = io
22
+ @pass = :green
23
+ @fail = :red
24
+ @error = :red
25
+ @skip = :yellow
26
+ end
27
+
28
+ def print o
29
+ case o
30
+ when '.' then io.print "\e[#{COLORS[pass]}m.\e[0m"
31
+ when 'E' then io.print "\e[#{COLORS[error]}mE\e[0m"
32
+ when 'F' then io.print "\e[#{COLORS[self.fail]}mF\e[0m"
33
+ when 'S' then io.print "\e[#{COLORS[skip]}mS\e[0m"
34
+ else
35
+ io.print o
36
+ end
37
+ end
38
+
39
+ def method_missing msg, *args
40
+ return super unless io.respond_to?(msg)
41
+ io.send(msg, *args)
42
+ end
43
+ end
44
+
45
+ ###
46
+ # Yields the current minitest output, which *should* be an instance
47
+ # of Purdytest::IO (hopefully).
48
+ def self.configure
49
+ yield MiniTest::Unit.output
50
+ end
51
+ end
52
+
53
+ MiniTest::Unit.output = Purdytest::IO.new(MiniTest::Unit.output)
54
+
55
+ if system("colordiff", __FILE__, __FILE__)
56
+ MiniTest::Assertions.diff = 'colordiff -u'
57
+ end
@@ -0,0 +1,31 @@
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
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: purdytest
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron Patterson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-06-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: &2156474540 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2156474540
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &2156474020 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.2
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2156474020
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ requirement: &2156473460 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 2.9.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2156473460
47
+ description: ! 'Purdytest extends minitest with pretty colors. Simply require minitest,
48
+ then
49
+
50
+ require purdytest, and you have colorific output on your terminal!
51
+
52
+
53
+ For colorized diff output, make sure you have `colordiff` installed.'
54
+ email:
55
+ - aaron@tenderlovemaking.com
56
+ executables: []
57
+ extensions: []
58
+ extra_rdoc_files:
59
+ - Manifest.txt
60
+ - CHANGELOG.rdoc
61
+ - README.rdoc
62
+ files:
63
+ - .autotest
64
+ - CHANGELOG.rdoc
65
+ - Manifest.txt
66
+ - README.rdoc
67
+ - Rakefile
68
+ - lib/purdytest.rb
69
+ - test/test_purdytest.rb
70
+ - .gemtest
71
+ homepage: http://github.com/tenderlove/purdytest
72
+ licenses: []
73
+ post_install_message:
74
+ rdoc_options:
75
+ - --main
76
+ - README.rdoc
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project: purdytest
93
+ rubygems_version: 1.8.5
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Purdytest extends minitest with pretty colors
97
+ test_files:
98
+ - test/test_purdytest.rb