minitest-colorize 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/CHANGELOG +4 -0
- data/lib/minitest/colorize.rb +33 -16
- data/lib/minitest/colorize/version.rb +1 -1
- data/minitest-colorize.gemspec +1 -0
- data/test/minitest_colorize_test.rb +8 -1
- data/test/test_helper.rb +2 -1
- metadata +14 -2
data/.travis.yml
ADDED
data/CHANGELOG
CHANGED
data/lib/minitest/colorize.rb
CHANGED
@@ -14,8 +14,13 @@ module MiniTest
|
|
14
14
|
def print(string = nil)
|
15
15
|
return stream.print if string.nil?
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
case string
|
18
|
+
when 'E', 'F'
|
19
|
+
stream.print red(string)
|
20
|
+
when 'S'
|
21
|
+
stream.print yellow(string)
|
22
|
+
when '.'
|
23
|
+
stream.print green(string)
|
19
24
|
else
|
20
25
|
stream.print string
|
21
26
|
end
|
@@ -32,17 +37,13 @@ module MiniTest
|
|
32
37
|
return stream.puts if string.nil?
|
33
38
|
|
34
39
|
if string =~ /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors, (\d+) skips/
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
colors['.']
|
43
|
-
end
|
44
|
-
|
45
|
-
stream.puts tint(color, string)
|
40
|
+
if $3 != '0' || $4 != '0'
|
41
|
+
stream.puts red(string)
|
42
|
+
elsif $5 != '0'
|
43
|
+
stream.puts yellow(string)
|
44
|
+
else
|
45
|
+
stream.puts green(string)
|
46
|
+
end
|
46
47
|
else
|
47
48
|
stream.puts string
|
48
49
|
end
|
@@ -54,12 +55,28 @@ module MiniTest
|
|
54
55
|
|
55
56
|
protected
|
56
57
|
|
58
|
+
def color_enabled?
|
59
|
+
stream.tty?
|
60
|
+
end
|
61
|
+
|
57
62
|
def tint(color, string)
|
58
|
-
|
63
|
+
if color_enabled?
|
64
|
+
"\e[#{color}m#{string}\e[0m"
|
65
|
+
else
|
66
|
+
string
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def red(string)
|
71
|
+
tint(31, string)
|
72
|
+
end
|
73
|
+
|
74
|
+
def green(string)
|
75
|
+
tint(32, string)
|
59
76
|
end
|
60
77
|
|
61
|
-
def
|
62
|
-
|
78
|
+
def yellow(string)
|
79
|
+
tint(33, string)
|
63
80
|
end
|
64
81
|
|
65
82
|
def report
|
data/minitest-colorize.gemspec
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class MiniTest::ColorizeTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
MiniTest::Colorize.any_instance.stubs(:color_enabled?).returns(true)
|
6
|
+
end
|
7
|
+
|
4
8
|
def test_print_fail
|
5
9
|
assert_output "\e[31mF\e[0m" do
|
6
10
|
colorize = MiniTest::Colorize.new
|
@@ -37,7 +41,10 @@ class MiniTest::ColorizeTest < MiniTest::Unit::TestCase
|
|
37
41
|
end
|
38
42
|
|
39
43
|
def test_print_without_arguments
|
40
|
-
|
44
|
+
# ruby 1.9 prints nothing and ruby 1.8 prints 'nil'
|
45
|
+
output = RUBY_VERSION >= '1.9' ? '' : 'nil'
|
46
|
+
|
47
|
+
assert_output output do
|
41
48
|
colorize = MiniTest::Colorize.new
|
42
49
|
colorize.print
|
43
50
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: minitest-colorize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Gabriel Sobrinho
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-07-18 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -35,6 +35,17 @@ dependencies:
|
|
35
35
|
version: 0.8.7
|
36
36
|
type: :development
|
37
37
|
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: mocha
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.9.12
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
38
49
|
description: Colorize MiniTest output and show failing tests instantly
|
39
50
|
email:
|
40
51
|
- gabriel.sobrinho@gmail.com
|
@@ -46,6 +57,7 @@ extra_rdoc_files: []
|
|
46
57
|
|
47
58
|
files:
|
48
59
|
- .gitignore
|
60
|
+
- .travis.yml
|
49
61
|
- CHANGELOG
|
50
62
|
- Gemfile
|
51
63
|
- README.markdown
|