guard-test 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/lib/guard/test/guard_test_runner.rb +25 -29
- data/lib/guard/test/notifier.rb +31 -27
- data/lib/guard/test/version.rb +1 -1
- metadata +10 -10
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.4.2 - November 19, 2011 - ([@rymai][])
|
2
|
+
|
3
|
+
### Bug fix:
|
4
|
+
|
5
|
+
- [#19](https://github.com/guard/guard-test/issues/19): Fixed "superclass mismatch for class Test (TypeError)" thanks to [@gertas][].
|
6
|
+
|
1
7
|
## 0.4.1 - November 3, 2011 - ([@rymai][])
|
2
8
|
|
3
9
|
### Bugs fixes:
|
@@ -96,6 +102,7 @@
|
|
96
102
|
|
97
103
|
[@Ask11]: https://github.com/Ask11
|
98
104
|
[@dasch]: https://github.com/dasch
|
105
|
+
[@gertas]: https://github.com/gertas
|
99
106
|
[@gregorymostizky]: https://github.com/gregorymostizky
|
100
107
|
[@jgrau]: https://github.com/jgrau
|
101
108
|
[@rymai]: https://github.com/rymai
|
@@ -9,35 +9,31 @@ require 'notifier'
|
|
9
9
|
#
|
10
10
|
# This class inherits from Test::Unit' standard console TestRunner
|
11
11
|
# I'm just overriding some callbacks methods to strip some outputs and display a notification on end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
@color_scheme["pass"] = ::Test::Unit::Color.new("green", :foreground => true, :bold => true)
|
19
|
-
@color_scheme["failure"] = ::Test::Unit::Color.new("red", :foreground => true, :bold => true)
|
20
|
-
end
|
21
|
-
|
22
|
-
protected
|
23
|
-
|
24
|
-
# Test::Unit::UI::Console::TestRunner overrided methods
|
25
|
-
def setup_mediator
|
26
|
-
@mediator = ::Test::Unit::UI::TestRunnerMediator.new(@suite)
|
27
|
-
end
|
28
|
-
|
29
|
-
def finished(elapsed_time)
|
30
|
-
super
|
31
|
-
::Guard::TestNotifier.notify(@result, elapsed_time)
|
32
|
-
nl
|
33
|
-
end
|
34
|
-
|
35
|
-
def fault_color_name(fault)
|
36
|
-
fault.class.name.split(/::/).last.downcase.to_sym
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
12
|
+
class GuardTestRunner < ::Test::Unit::UI::Console::TestRunner
|
13
|
+
|
14
|
+
def initialize(suite, options = {})
|
15
|
+
super
|
16
|
+
@color_scheme["pass"] = ::Test::Unit::Color.new("green", :foreground => true, :bold => true)
|
17
|
+
@color_scheme["failure"] = ::Test::Unit::Color.new("red", :foreground => true, :bold => true)
|
40
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 finished(elapsed_time)
|
28
|
+
super
|
29
|
+
::Guard::Test::Notifier.notify(@result, elapsed_time)
|
30
|
+
nl
|
31
|
+
end
|
32
|
+
|
33
|
+
def fault_color_name(fault)
|
34
|
+
fault.class.name.split(/::/).last.downcase.to_sym
|
35
|
+
end
|
36
|
+
|
41
37
|
end
|
42
38
|
|
43
|
-
Test::Unit::AutoRunner.register_runner(:guard) { |r|
|
39
|
+
Test::Unit::AutoRunner.register_runner(:guard) { |r| GuardTestRunner }
|
data/lib/guard/test/notifier.rb
CHANGED
@@ -1,41 +1,45 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
2
3
|
require 'guard'
|
4
|
+
require 'guard/guard'
|
3
5
|
require 'guard/notifier'
|
4
6
|
|
5
7
|
module Guard
|
6
|
-
|
8
|
+
class Test < Guard
|
9
|
+
module Notifier
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
class << self
|
12
|
+
def notify(result, elapsed_time)
|
13
|
+
::Guard::Notifier.notify(
|
14
|
+
summary(result) + "\n\n" + duration(elapsed_time),
|
15
|
+
:title => "Test::Unit results",
|
16
|
+
:image => result.failure_count > 0 ? :failed : :success
|
17
|
+
)
|
18
|
+
end
|
16
19
|
|
17
|
-
|
20
|
+
private
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def summary(result)
|
23
|
+
"#{result.run_count} test#{'s' if result.run_count != 1}, " +
|
24
|
+
"#{result.assertion_count} assert#{'s' if result.assertion_count != 1}, " +
|
25
|
+
"#{result.failure_count} fail#{'s' if result.failure_count != 1}, " +
|
26
|
+
"#{result.error_count} error#{'s' if result.error_count != 1}"
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
def duration(duration, options = {})
|
30
|
+
"Finished in #{round_float(duration)} seconds"
|
31
|
+
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def round_float(float, decimals = 4)
|
34
|
+
if Float.instance_method(:round).arity == 0 # Ruby 1.8
|
35
|
+
factor = 10**decimals
|
36
|
+
(float*factor).round / factor.to_f
|
37
|
+
else # Ruby 1.9
|
38
|
+
float.round(decimals)
|
39
|
+
end
|
36
40
|
end
|
37
41
|
end
|
38
|
-
end
|
39
42
|
|
43
|
+
end
|
40
44
|
end
|
41
|
-
end
|
45
|
+
end
|
data/lib/guard/test/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
16
|
-
requirement: &
|
16
|
+
requirement: &70255487678060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.4'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70255487678060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test-unit
|
27
|
-
requirement: &
|
27
|
+
requirement: &70255487677600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70255487677600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70255487677140 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70255487677140
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70255487676680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '2.6'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70255487676680
|
58
58
|
description: Guard::Test automatically run your tests on file modification.
|
59
59
|
email:
|
60
60
|
- rymai@rymai.me
|