minitest-colorize 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ tmp
data/CHANGELOG ADDED
@@ -0,0 +1,14 @@
1
+ 0.0.3 [Mon Jun 27 2011]
2
+
3
+ * Show failing tests instantly
4
+
5
+ 0.0.2 [Sat Jun 25 2011]
6
+
7
+ * Fix missing require to minitest
8
+ * Colorize status output
9
+ * MiniTest::Colorize#print now accepts call without arguments
10
+ * MiniTest::Colorize#tint, MiniTest::Colorize#colors, and MiniTest::Colorize#clear should be protected
11
+
12
+ 0.0.1 [Fri Jun 24 2011]
13
+
14
+ * First release
data/README.markdown ADDED
@@ -0,0 +1,10 @@
1
+ MiniTest Colorize
2
+ =================
3
+
4
+ Colorize MiniTest output and show failing tests instantly
5
+
6
+
7
+ Examples
8
+ ========
9
+
10
+ ![example](https://github.com/sobrinho/minitest-colorize/raw/master/examples/example.png)
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  module MiniTest
2
2
  class Colorize
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -3,24 +3,33 @@ require "minitest/unit"
3
3
 
4
4
  module MiniTest
5
5
  class Colorize
6
- attr_accessor :io
6
+ attr_accessor :stream
7
7
 
8
- def initialize(io)
9
- self.io = io
8
+ def initialize(stream = $stdout)
9
+ self.stream = stream.tap do |stream|
10
+ stream.sync = true if stream.respond_to?(:sync=)
11
+ end
10
12
  end
11
13
 
12
14
  def print(string = nil)
13
- return io.print if string.nil?
15
+ return stream.print if string.nil?
14
16
 
15
17
  if color = colors[string]
16
- io.print tint(color, string)
18
+ stream.print tint(color, string)
17
19
  else
18
- io.print string
20
+ stream.print string
21
+ end
22
+
23
+ unless report.empty?
24
+ stream.puts
25
+ stream.puts
26
+ stream.puts report.shift
27
+ stream.puts
19
28
  end
20
29
  end
21
30
 
22
31
  def puts(string = nil)
23
- return io.puts if string.nil?
32
+ return stream.puts if string.nil?
24
33
 
25
34
  if string =~ /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors, (\d+) skips/
26
35
  color = if $3 != '0'
@@ -33,14 +42,14 @@ module MiniTest
33
42
  colors['.']
34
43
  end
35
44
 
36
- io.puts tint(color, string)
45
+ stream.puts tint(color, string)
37
46
  else
38
- io.puts string
47
+ stream.puts string
39
48
  end
40
49
  end
41
50
 
42
51
  def method_missing(method, *args, &block)
43
- io.send(method, *args, &block)
52
+ stream.send(method, *args, &block)
44
53
  end
45
54
 
46
55
  protected
@@ -52,7 +61,11 @@ module MiniTest
52
61
  def colors
53
62
  { "F" => 31, "E" => 31, "S" => 33, "." => 32 }
54
63
  end
64
+
65
+ def report
66
+ MiniTest::Unit.runner.report
67
+ end
55
68
  end
56
69
  end
57
70
 
58
- MiniTest::Unit.output = MiniTest::Colorize.new(MiniTest::Unit.output)
71
+ MiniTest::Unit.output = MiniTest::Colorize.new
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Gabriel Sobrinho"]
9
9
  s.email = ["gabriel.sobrinho@gmail.com"]
10
10
  s.homepage = ""
11
- s.summary = %q{Colorize minitest output}
12
- s.description = %q{Colorize minitest output}
11
+ s.summary = %q{Colorize MiniTest output and show failing tests instantly}
12
+ s.description = %q{Colorize MiniTest output and show failing tests instantly}
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -3,84 +3,84 @@ require 'test_helper'
3
3
  class MiniTest::ColorizeTest < MiniTest::Unit::TestCase
4
4
  def test_print_fail
5
5
  assert_output "\e[31mF\e[0m" do
6
- colorize = MiniTest::Colorize.new($stdout)
6
+ colorize = MiniTest::Colorize.new
7
7
  colorize.print 'F'
8
8
  end
9
9
  end
10
10
 
11
11
  def test_print_error
12
12
  assert_output "\e[31mE\e[0m" do
13
- colorize = MiniTest::Colorize.new($stdout)
13
+ colorize = MiniTest::Colorize.new
14
14
  colorize.print 'E'
15
15
  end
16
16
  end
17
17
 
18
18
  def test_print_skip
19
19
  assert_output "\e[33mS\e[0m" do
20
- colorize = MiniTest::Colorize.new($stdout)
20
+ colorize = MiniTest::Colorize.new
21
21
  colorize.print 'S'
22
22
  end
23
23
  end
24
24
 
25
25
  def test_print_success
26
26
  assert_output "\e[32m.\e[0m" do
27
- colorize = MiniTest::Colorize.new($stdout)
27
+ colorize = MiniTest::Colorize.new
28
28
  colorize.print '.'
29
29
  end
30
30
  end
31
31
 
32
32
  def test_print
33
33
  assert_output "colorize" do
34
- colorize = MiniTest::Colorize.new($stdout)
34
+ colorize = MiniTest::Colorize.new
35
35
  colorize.print 'colorize'
36
36
  end
37
37
  end
38
38
 
39
39
  def test_print_without_arguments
40
- assert_output '' do
41
- colorize = MiniTest::Colorize.new($stdout)
40
+ assert_output "" do
41
+ colorize = MiniTest::Colorize.new
42
42
  colorize.print
43
43
  end
44
44
  end
45
45
 
46
46
  def test_puts_fail
47
47
  assert_output "\e[31m12 tests, 12 assertions, 4 failures, 0 errors, 0 skips\e[0m\n" do
48
- colorize = MiniTest::Colorize.new($stdout)
48
+ colorize = MiniTest::Colorize.new
49
49
  colorize.puts '12 tests, 12 assertions, 4 failures, 0 errors, 0 skips'
50
50
  end
51
51
  end
52
52
 
53
53
  def test_puts_error
54
54
  assert_output "\e[31m12 tests, 12 assertions, 0 failures, 4 errors, 0 skips\e[0m\n" do
55
- colorize = MiniTest::Colorize.new($stdout)
55
+ colorize = MiniTest::Colorize.new
56
56
  colorize.puts '12 tests, 12 assertions, 0 failures, 4 errors, 0 skips'
57
57
  end
58
58
  end
59
59
 
60
60
  def test_puts_skip
61
61
  assert_output "\e[33m12 tests, 12 assertions, 0 failures, 0 errors, 4 skips\e[0m\n" do
62
- colorize = MiniTest::Colorize.new($stdout)
62
+ colorize = MiniTest::Colorize.new
63
63
  colorize.puts '12 tests, 12 assertions, 0 failures, 0 errors, 4 skips'
64
64
  end
65
65
  end
66
66
 
67
67
  def test_puts_success
68
68
  assert_output "\e[32m12 tests, 12 assertions, 0 failures, 0 errors, 0 skips\e[0m\n" do
69
- colorize = MiniTest::Colorize.new($stdout)
69
+ colorize = MiniTest::Colorize.new
70
70
  colorize.puts '12 tests, 12 assertions, 0 failures, 0 errors, 0 skips'
71
71
  end
72
72
  end
73
73
 
74
74
  def test_puts
75
75
  assert_output "colorize\n" do
76
- colorize = MiniTest::Colorize.new($stdout)
76
+ colorize = MiniTest::Colorize.new
77
77
  colorize.puts 'colorize'
78
78
  end
79
79
  end
80
80
 
81
81
  def test_puts_without_arguments
82
82
  assert_output "\n" do
83
- colorize = MiniTest::Colorize.new($stdout)
83
+ colorize = MiniTest::Colorize.new
84
84
  colorize.puts
85
85
  end
86
86
  end
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.2
5
+ version: 0.0.3
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-06-25 00:00:00 -03:00
13
+ date: 2011-06-27 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: 0.8.7
36
36
  type: :development
37
37
  version_requirements: *id002
38
- description: Colorize minitest output
38
+ description: Colorize MiniTest output and show failing tests instantly
39
39
  email:
40
40
  - gabriel.sobrinho@gmail.com
41
41
  executables: []
@@ -46,8 +46,12 @@ extra_rdoc_files: []
46
46
 
47
47
  files:
48
48
  - .gitignore
49
+ - CHANGELOG
49
50
  - Gemfile
51
+ - README.markdown
50
52
  - Rakefile
53
+ - examples/example.png
54
+ - examples/success.png
51
55
  - lib/minitest-colorize.rb
52
56
  - lib/minitest/colorize.rb
53
57
  - lib/minitest/colorize/version.rb
@@ -81,7 +85,7 @@ rubyforge_project:
81
85
  rubygems_version: 1.5.2
82
86
  signing_key:
83
87
  specification_version: 3
84
- summary: Colorize minitest output
88
+ summary: Colorize MiniTest output and show failing tests instantly
85
89
  test_files:
86
90
  - test/minitest_colorize_test.rb
87
91
  - test/test_helper.rb