guard-test 0.3.1 → 0.4.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.
@@ -1,64 +0,0 @@
1
- # encoding: utf-8
2
- $:.push File.expand_path('../../../', File.dirname(__FILE__))
3
-
4
- require 'test/unit/ui/console/testrunner'
5
- require 'guard/test/ui'
6
- require 'guard/test/notifier'
7
-
8
- # Thanks to Adam Sanderson for the really good starting point:
9
- # http://endofline.wordpress.com/2008/02/11/a-custom-testrunner-to-scratch-an-itch/
10
- #
11
- # This class inherits from Test::Unit' standard console TestRunner
12
- # I'm just overriding some callbacks methods to display some nicer results
13
- class DefaultGuardTestRunner < Test::Unit::UI::Console::TestRunner
14
-
15
- def initialize(suite, options={})
16
- super
17
- @use_color = true
18
- end
19
-
20
- protected
21
-
22
- # Test::Unit::UI::Console::TestRunner overrided methods
23
- def setup_mediator
24
- @mediator = Test::Unit::UI::TestRunnerMediator.new(@suite)
25
- end
26
-
27
- def started(result)
28
- @result = result
29
- nl
30
- end
31
-
32
- def test_started(name)
33
- # silence!
34
- end
35
-
36
- def add_fault(fault)
37
- @faults << fault
38
- Guard::TestUI.color_print(fault.single_character_display, :color => fault_color_name(fault))
39
- @was_faulty = true
40
- end
41
-
42
- def test_finished(name)
43
- Guard::TestUI.color_print(".", :color => :pass) unless @was_faulty
44
- @was_faulty = false
45
- end
46
-
47
- def finished(elapsed_time)
48
- Guard::TestNotifier.notify(@result, elapsed_time)
49
- nl;nl
50
- @faults.each_with_index do |fault, index|
51
- Guard::TestUI.color_puts("%3d) %s" % [index + 1, fault.long_display], :color => fault_color_name(fault))
52
- nl
53
- end
54
- Guard::TestUI.results(@result, elapsed_time)
55
- nl
56
- end
57
-
58
- def fault_color_name(fault)
59
- fault.class.name.split(/::/).last.downcase.to_sym
60
- end
61
-
62
- end
63
-
64
- Test::Unit::AutoRunner.register_runner(:"guard-default") { |r| DefaultGuardTestRunner }