kule-redgreen 0.1.0

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.
data/README.markdown ADDED
@@ -0,0 +1,64 @@
1
+ # kule-redgreen
2
+
3
+ kule-redgreen is a fork of Pat Eyler's & Chris Wanstrath's RedGreen.
4
+
5
+ I had problems with autotest only running once and then stopping (rather than continuously testing new updates).
6
+
7
+ This version works using ZenTest 4.0.0 on XP & Vista.
8
+
9
+ ## Install the gem
10
+
11
+ gem install kule-redgreen -s http://gems.github.com
12
+
13
+ NB. Don't forget to uninstall the old redgreen gem if you are using it:
14
+
15
+ gem uninstall redgreen
16
+
17
+ ## Autotest & Snarl Setup
18
+
19
+ See here to set up your windows environment:
20
+ [http://thewebfellas.com/blog/2007/12/10/rspec-autotest-and-snarl-on-windows](http://thewebfellas.com/blog/2007/12/10/rspec-autotest-and-snarl-on-windows)
21
+
22
+ In your `.autotest` file you just need the following (used for tests/shoulda):
23
+
24
+ require 'autotest/snarl'
25
+ require 'Win32/Console/ANSI'
26
+ require 'redgreen/autotest'
27
+
28
+ ## Snarl Issue (Tests always Pass)
29
+
30
+ Currently to allow Snarl to work with ZenTest 4.0.0 you need to modify autotest.rb file
31
+ (Usually: `C:\Ruby\lib\ruby\gems\1.8\gems\ZenTest-4.0.0\lib\` ):
32
+
33
+ Change this line:
34
+ self.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)/
35
+
36
+ To:
37
+ self.failed_results_re = /^\s+\d+\) (?:\e\[\d+m)?(?:Failure|Error)(?:\e\[0m)?:\n(.*?)\((.*?)\)/
38
+
39
+ This then allows the regular expression to ignore the colour escape codes and it picks up the correct amount of failures.
40
+
41
+ FYI I'll pop an email over to the ZenTest guys to see if they are okay to make this change.
42
+
43
+ ## Other Minor Changes
44
+
45
+ Changed the colour scheme from foreground to background colours as I find it a little easier on the eyes!
46
+
47
+ Luke Pearce
48
+ www.kulesolutions.com
49
+
50
+ ### Previous README comments:
51
+
52
+ Use it as you would the ruby interpreter when running your unit test.
53
+
54
+ Like so:
55
+
56
+ rg test/test_units.rb
57
+
58
+ Relevant bloggings:
59
+
60
+ * [http://errtheblog.com/post/15](http://errtheblog.com/post/15)
61
+ * [http://on-ruby.blogspot.com/2006/05/red-and-green-for-ruby.html](http://on-ruby.blogspot.com/2006/05/red-and-green-for-ruby.html)
62
+
63
+ Enjoy.
64
+
data/bin/rg ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'redgreen'
4
+ require 'win32console' if PLATFORM =~ /win32/
5
+
6
+ require $0 = ARGV.first
@@ -0,0 +1,4 @@
1
+ Autotest.send(:alias_method, :real_ruby, :ruby)
2
+ Autotest.send(:define_method, :ruby) do |*args|
3
+ real_ruby + %[ -rrubygems -e "require 'redgreen'" ]
4
+ end
data/lib/redgreen.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'test/unit'
2
+ require 'test/unit/ui/console/testrunner'
3
+
4
+ # cute.
5
+ module Color
6
+ COLORS = { :clear => 0, :red => 41, :green => 42, :yellow => 43 }
7
+ def self.method_missing(color_name, *args)
8
+ color(color_name) + args.first + color(:clear)
9
+ end
10
+ def self.color(color)
11
+ "\e[#{COLORS[color.to_sym]}m"
12
+ end
13
+ end
14
+
15
+ class Test::Unit::UI::Console::RedGreenTestRunner < Test::Unit::UI::Console::TestRunner
16
+ def initialize(suite, output_level=NORMAL, io=$stdout)
17
+ super
18
+ end
19
+
20
+ def output_single(something, level=NORMAL)
21
+ return unless (output?(level))
22
+ something = case something
23
+ when '.' then Color.green('.')
24
+ when 'F' then Color.red("F")
25
+ when 'E' then Color.yellow("E")
26
+ else something
27
+ end
28
+ @io.write(something)
29
+ @io.flush
30
+ end
31
+ end
32
+
33
+ class Test::Unit::AutoRunner
34
+ alias :old_initialize :initialize
35
+ def initialize(standalone)
36
+ old_initialize(standalone)
37
+ @runner = proc do |r|
38
+ Test::Unit::UI::Console::RedGreenTestRunner
39
+ end
40
+ end
41
+ end
42
+
43
+ class Test::Unit::TestResult
44
+ alias :old_to_s :to_s
45
+ def to_s
46
+ if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
47
+ Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&)
48
+ end
49
+ end
50
+ end
51
+
52
+ class Test::Unit::Failure
53
+ alias :old_long_display :long_display
54
+ def long_display
55
+ old_long_display.sub('Failure', Color.red('Failure'))
56
+ end
57
+ end
58
+
59
+ class Test::Unit::Error
60
+ alias :old_long_display :long_display
61
+ def long_display
62
+ old_long_display.sub('Error', Color.yellow('Error'))
63
+ end
64
+ end
data/redgreen.gemspec ADDED
@@ -0,0 +1,42 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{redgreen}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Pat Eyler", "Chris Wanstrath", "Luke Pearce"]
9
+ s.date = %q{2009-04-06}
10
+ s.default_executable = %q{rg}
11
+ s.description = %q{kule-redgreen colourises windows console output for tests. This version works with ZenTest 4.0.0, autotest, snarl, XP and Vista. Please see the README file for setup or issues with Snarl.}
12
+ s.email = %q{github@kulesolutions.com}
13
+ s.executables = ["rg"]
14
+ s.extra_rdoc_files = [
15
+ "README.markdown"
16
+ ]
17
+ s.files = [
18
+ "README.markdown",
19
+ "Rakefile",
20
+ "bin/rg",
21
+ "lib/redgreen.rb",
22
+ "lib/redgreen/autotest.rb",
23
+ "redgreen.gemspec",
24
+ "version.yml"
25
+ ]
26
+ s.has_rdoc = true
27
+ s.homepage = %q{http://github.com/kule/redgreen}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.1}
31
+ s.summary = %q{kule-redgreen colourises windows console output for tests.}
32
+
33
+ if s.respond_to? :specification_version then
34
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
35
+ s.specification_version = 2
36
+
37
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
38
+ else
39
+ end
40
+ else
41
+ end
42
+ end
data/version.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 0
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kule-redgreen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pat Eyler
8
+ - Chris Wanstrath
9
+ - Luke Pearce
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-04-06 00:00:00 -07:00
15
+ default_executable: rg
16
+ dependencies: []
17
+
18
+ description: kule-redgreen colourises windows console output for tests. This version works with ZenTest 4.0.0, autotest, snarl, XP and Vista. Please see the README file for setup or issues with Snarl.
19
+ email: github@kulesolutions.com
20
+ executables:
21
+ - rg
22
+ extensions: []
23
+
24
+ extra_rdoc_files:
25
+ - README.markdown
26
+ files:
27
+ - README.markdown
28
+ - Rakefile
29
+ - bin/rg
30
+ - lib/redgreen.rb
31
+ - lib/redgreen/autotest.rb
32
+ - redgreen.gemspec
33
+ - version.yml
34
+ has_rdoc: true
35
+ homepage: http://github.com/kule/redgreen
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --charset=UTF-8
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 1.2.0
57
+ signing_key:
58
+ specification_version: 2
59
+ summary: kule-redgreen colourises windows console output for tests.
60
+ test_files: []
61
+