turn 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.
Files changed (2) hide show
  1. data/lib/turn.rb +99 -0
  2. metadata +54 -0
data/lib/turn.rb ADDED
@@ -0,0 +1,99 @@
1
+ # $Id$
2
+
3
+ require 'test/unit/ui/console/testrunner'
4
+ begin
5
+ require 'facets/more/ansicode'
6
+ rescue LoadError
7
+ begin
8
+ require 'rubygems'
9
+ require 'facets/more/ansicode'
10
+ rescue LoadError
11
+ end
12
+ end
13
+
14
+
15
+ module ::Test::Unit
16
+ module UI
17
+ module Console
18
+ class TestRunner
19
+
20
+ def attach_to_mediator
21
+ @mediator.add_listener(TestRunnerMediator::STARTED, &method(:p_started))
22
+ @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:p_finished))
23
+ @mediator.add_listener(TestCase::STARTED, &method(:p_test_started))
24
+ @mediator.add_listener(TestCase::FINISHED, &method(:p_test_finished))
25
+ @mediator.add_listener(TestResult::FAULT, &method(:p_fault))
26
+ @io.sync = true
27
+ end
28
+
29
+ def p_started( result )
30
+ @p_result = result
31
+ end
32
+
33
+ def p_finished( elapsed_time )
34
+ failure = @p_result.failure_count
35
+ error = @p_result.error_count
36
+ total = @p_result.run_count
37
+ pass = total - failure - error
38
+
39
+ bar = '=' * 78
40
+ if COLORIZE
41
+ bar = if pass == total then ::Console::ANSICode.green bar
42
+ else ::Console::ANSICode.red bar end
43
+ end
44
+
45
+ @io.puts bar
46
+ @io.puts " pass: %d, fail: %d, error: %d" % [pass, failure, error]
47
+ @io.puts " total: %d tests with %d assertions in #{elapsed_time} seconds" % [total, @p_result.assertion_count]
48
+ @io.puts bar
49
+ end
50
+
51
+ def p_test_started( name )
52
+ method, file = name.scan(%r/^([^\(]+)\(([^\)]+)\)/o).flatten!
53
+ if @p_cur_file != file
54
+ @p_cur_file = file
55
+ @io.puts file
56
+ end
57
+ @io.print " %-69s" % method
58
+ end
59
+
60
+ def p_test_finished( name )
61
+ @io.puts PASS unless @p_fault
62
+ @p_fault = false
63
+ end
64
+
65
+ def p_fault( fault )
66
+ @p_fault = true
67
+ msg = "\t"
68
+
69
+ case fault
70
+ when ::Test::Unit::Error
71
+ @io.puts ERROR
72
+ msg << fault.to_s.split("\n")[2..-1].join("\n\t")
73
+ when ::Test::Unit::Failure
74
+ @io.puts FAIL
75
+ msg << fault.location[0] << "\n\t"
76
+ msg << fault.message.gsub("\n","\n\t")
77
+ end
78
+
79
+ msg = ::Console::ANSICode.magenta msg if COLORIZE
80
+ @io.puts msg
81
+ end
82
+
83
+ COLORIZE = defined?(::Console::ANSICode) && ENV.has_key?('TERM')
84
+ if COLORIZE
85
+ PASS = ::Console::ANSICode.green ' PASS'
86
+ FAIL = ::Console::ANSICode.red ' FAIL'
87
+ ERROR = ::Console::ANSICode.white(
88
+ ::Console::ANSICode.on_red('ERROR'))
89
+ else
90
+ PASS = " PASS"
91
+ FAIL = " FAIL"
92
+ ERROR = "ERROR"
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ # EOF
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: turn
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2006-11-10 00:00:00 -07:00
8
+ summary: Test::Unit Reporter New -- new output format for Test::Unit
9
+ require_paths:
10
+ - lib
11
+ email: tim.pease@gmail.com
12
+ homepage:
13
+ rubyforge_project: codeforpeople.com
14
+ description: "Turn this ..F..... Into this TestMyClass test_alt PASS test_alt_eq PASS test_bad FAIL ./test/test_my_class.rb:64:in `test_bad' <false> is not true. test_foo PASS test_foo_eq PASS TestYourClass test_method_a PASS test_method_b PASS test_method_c PASS ============================================================================ pass: 7, fail: 1, error: 0 total: 15 tests with 42 assertions in 0.018 seconds ============================================================================ By doing this require 'turn' And, if the 'facets' gem is installed (and your terminal supports ANSI color codes) all this will be printed out in glorious and amazing technicolor!"
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Tim Pease
31
+ files:
32
+ - lib/turn.rb
33
+ test_files: []
34
+
35
+ rdoc_options: []
36
+
37
+ extra_rdoc_files: []
38
+
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ requirements: []
44
+
45
+ dependencies:
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Version::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.1.3
54
+ version: