arfl-redgreen 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
+ [http://www.kulesolutions.com](http://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
+
@@ -0,0 +1,25 @@
1
+ require 'rake'
2
+
3
+ $LOAD_PATH.unshift('lib')
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "redgreen"
9
+ gem.summary = "arfl-redgreen colourises windows console output for tests."
10
+ gem.email = "andreas.riemer@gmail.com"
11
+ gem.homepage = "http://github.com/arfl/redgreen"
12
+ gem.description = "This gem is a fork from kule-redgreen. Go and check it out, then needed at http://github.com/kule/redgreen. arfl-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."
13
+ gem.authors = ["Pat Eyler", "Chris Wanstrath", "Luke Pearce"]
14
+ end
15
+ rescue LoadError
16
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
17
+ end
18
+
19
+ require 'rake/rdoctask'
20
+ Rake::RDocTask.new do |rdoc|
21
+ rdoc.rdoc_dir = 'rdoc'
22
+ rdoc.title = 'arfl-redgreen'
23
+ rdoc.rdoc_files.include('README.markdown')
24
+ rdoc.rdoc_files.include('lib/**/*.rb')
25
+ end
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,66 @@
1
+ require 'test/unit'
2
+ require 'test/unit/ui/console/testrunner'
3
+
4
+ # cute.
5
+ module RedGreen
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
+ end
16
+
17
+ class Test::Unit::UI::Console::RedGreenTestRunner < Test::Unit::UI::Console::TestRunner
18
+ def initialize(suite, output_level=NORMAL, io=$stdout)
19
+ super
20
+ end
21
+
22
+ def output_single(something, level=NORMAL)
23
+ return unless (output?(level))
24
+ something = case something
25
+ when '.' then RedGreen::Color.green('.')
26
+ when 'F' then RedGreen::Color.red("F")
27
+ when 'E' then RedGreen::Color.yellow("E")
28
+ else something
29
+ end
30
+ @io.write(something)
31
+ @io.flush
32
+ end
33
+ end
34
+
35
+ class Test::Unit::AutoRunner
36
+ alias :old_initialize :initialize
37
+ def initialize(standalone)
38
+ old_initialize(standalone)
39
+ @runner = proc do |r|
40
+ Test::Unit::UI::Console::RedGreenTestRunner
41
+ end
42
+ end
43
+ end
44
+
45
+ class Test::Unit::TestResult
46
+ alias :old_to_s :to_s
47
+ def to_s
48
+ if old_to_s =~ /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors/
49
+ RedGreen::Color.send($1.to_i != 0 || $2.to_i != 0 ? :red : :green, $&)
50
+ end
51
+ end
52
+ end
53
+
54
+ class Test::Unit::Failure
55
+ alias :old_long_display :long_display
56
+ def long_display
57
+ old_long_display.sub('Failure', RedGreen::Color.red('Failure'))
58
+ end
59
+ end
60
+
61
+ class Test::Unit::Error
62
+ alias :old_long_display :long_display
63
+ def long_display
64
+ old_long_display.sub('Error', RedGreen::Color.yellow('Error'))
65
+ end
66
+ end
@@ -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
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arfl-redgreen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
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-05-08 00:00:00 -07:00
15
+ default_executable: rg
16
+ dependencies: []
17
+
18
+ description: This gem is a fork from kule-redgreen. Go and check it out, then needed at http://github.com/kule/redgreen. arfl-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: andreas.riemer@gmail.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
+ has_rdoc: true
33
+ homepage: http://github.com/arfl/redgreen
34
+ post_install_message:
35
+ rdoc_options:
36
+ - --charset=UTF-8
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.2.0
55
+ signing_key:
56
+ specification_version: 2
57
+ summary: arfl-redgreen colourises windows console output for tests.
58
+ test_files: []
59
+