redgreen 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README +17 -0
  2. data/bin/rg +4 -0
  3. data/lib/redgreen.rb +61 -0
  4. data/test/test_fake.rb +33 -0
  5. metadata +51 -0
data/README ADDED
@@ -0,0 +1,17 @@
1
+ == redgreen
2
+
3
+ redgreen is an expanded version of Pat Eyler's RedGreen. Use it as you would
4
+ the ruby interpreter when running your unit test.
5
+
6
+ Like so:
7
+
8
+ $ rg test/test_units.rb
9
+
10
+ Relevant bloggings:
11
+ - http://errtheblog.com/post/15
12
+ - http://on-ruby.blogspot.com/2006/05/red-and-green-for-ruby.html
13
+
14
+ Enjoy.
15
+
16
+ >> Chris Wanstrath
17
+ => chris[at]ozmm[dot]org
data/bin/rg ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'redgreen'
4
+ require $0 = ARGV.first
@@ -0,0 +1,61 @@
1
+ require 'Win32/Console/ANSI' if PLATFORM =~ /win32/
2
+ require 'test/unit'
3
+ require 'test/unit/ui/console/testrunner'
4
+
5
+ # cute.
6
+ module Color
7
+ COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33 }
8
+ def self.method_missing(color_name, *args)
9
+ color(color_name) + args.first + color(:clear)
10
+ end
11
+ def self.color(color)
12
+ "\e[#{COLORS[color.to_sym]}m"
13
+ end
14
+ end
15
+
16
+ class Test::Unit::UI::Console::RedGreenTestRunner < Test::Unit::UI::Console::TestRunner
17
+ def output_single(something, level=NORMAL)
18
+ return unless (output?(level))
19
+ something = case something
20
+ when '.' then Color.green('.')
21
+ when 'F' then Color.red("F")
22
+ when 'E' then Color.yellow("E")
23
+ else something
24
+ end
25
+ @io.write(something)
26
+ @io.flush
27
+ end
28
+ end
29
+
30
+ class Test::Unit::AutoRunner
31
+ alias :old_initialize :initialize
32
+ def initialize(standalone)
33
+ old_initialize(standalone)
34
+ @runner = proc do |r|
35
+ Test::Unit::UI::Console::RedGreenTestRunner
36
+ end
37
+ end
38
+ end
39
+
40
+ class Test::Unit::TestResult
41
+ alias :old_to_s :to_s
42
+ def to_s
43
+ if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
44
+ Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&)
45
+ end
46
+ end
47
+ end
48
+
49
+ class Test::Unit::Failure
50
+ alias :old_long_display :long_display
51
+ def long_display
52
+ old_long_display.sub('Failure', Color.red('Failure'))
53
+ end
54
+ end
55
+
56
+ class Test::Unit::Error
57
+ alias :old_long_display :long_display
58
+ def long_display
59
+ old_long_display.sub('Error', Color.yellow('Error'))
60
+ end
61
+ end
@@ -0,0 +1,33 @@
1
+ require 'test/unit'
2
+
3
+ class TestFake < Test::Unit::TestCase
4
+
5
+ def test_true
6
+ assert true
7
+ end
8
+
9
+ def test_fail
10
+ assert false
11
+ end
12
+
13
+ def test_true_2
14
+ assert true
15
+ end
16
+
17
+ def test_true_3
18
+ assert true
19
+ end
20
+
21
+ def test_error
22
+ assert method_dont_exist
23
+ end
24
+
25
+ def test_true_4
26
+ assert true
27
+ end
28
+
29
+ def test_fail_again
30
+ assert false
31
+ end
32
+
33
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: redgreen
5
+ version: !ruby/object:Gem::Version
6
+ version: "1.2"
7
+ date: 2006-11-09 00:00:00 -08:00
8
+ summary: redgreen is an expanded version of Pat Eyler's RedGreen
9
+ require_paths:
10
+ - lib
11
+ email:
12
+ - chris@ozmm.org
13
+ - pat.eyler@gmail.com
14
+ homepage: http://errtheblog.com/post/15, http://on-ruby.blogspot.com/
15
+ rubyforge_project:
16
+ description: redgreen is an expanded version of Pat Eyler's RedGreen. It will install a 'rg' file in your bin directory. Use that as you would use 'ruby' when running a test.
17
+ autorequire: redgreen
18
+ default_executable:
19
+ bindir: bin
20
+ has_rdoc: false
21
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
22
+ requirements:
23
+ - - ">"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.0.0
26
+ version:
27
+ platform: ruby
28
+ signing_key:
29
+ cert_chain:
30
+ post_install_message:
31
+ authors:
32
+ - Chris Wanstrath and Pat Eyler
33
+ files:
34
+ - README
35
+ - bin/rg
36
+ - lib/redgreen.rb
37
+ - test/test_fake.rb
38
+ test_files: []
39
+
40
+ rdoc_options: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ executables:
45
+ - rg
46
+ extensions: []
47
+
48
+ requirements: []
49
+
50
+ dependencies: []
51
+