guard-test 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +20 -12
- data/README.md +23 -45
- data/lib/guard/test/guard_test_runner.rb +48 -0
- data/lib/guard/test/{runners/default_test_unit_runner.rbc → guard_test_runner.rbc} +596 -568
- data/lib/guard/test/inspector.rbc +473 -161
- data/lib/guard/test/notifier.rb +30 -7
- data/lib/guard/test/notifier.rbc +680 -60
- data/lib/guard/test/runner.rb +43 -28
- data/lib/guard/test/runner.rbc +412 -703
- data/lib/guard/test/templates/Guardfile +1 -1
- data/lib/guard/test/version.rb +1 -1
- data/lib/guard/test/version.rbc +61 -11
- data/lib/guard/test.rb +1 -1
- data/lib/guard/test.rbc +245 -142
- metadata +14 -22
- data/lib/guard/test/result_helpers.rb +0 -28
- data/lib/guard/test/result_helpers.rbc +0 -798
- data/lib/guard/test/runners/default_guard_test_runner.rb +0 -64
- data/lib/guard/test/runners/default_guard_test_runner.rbc +0 -1442
- data/lib/guard/test/runners/fastfail_guard_test_runner.rb +0 -29
- data/lib/guard/test/runners/fastfail_guard_test_runner.rbc +0 -596
- data/lib/guard/test/runners/fastfail_test_unit_runner.rbc +0 -562
- data/lib/guard/test/ui.rb +0 -38
- data/lib/guard/test/ui.rbc +0 -1053
data/lib/guard/test/notifier.rb
CHANGED
@@ -1,17 +1,40 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'guard'
|
3
3
|
require 'guard/notifier'
|
4
|
-
require 'guard/test/result_helpers'
|
5
4
|
|
6
5
|
module Guard
|
7
6
|
module TestNotifier
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
::Guard::
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
class << self
|
9
|
+
def notify(result, elapsed_time)
|
10
|
+
::Guard::Notifier.notify(
|
11
|
+
summary(result) + "\n\n" + duration(elapsed_time),
|
12
|
+
:title => "Test::Unit results",
|
13
|
+
:image => result.failure_count > 0 ? :failed : :success
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def summary(result)
|
20
|
+
"#{result.run_count} test#{'s' if result.run_count != 1}, " \
|
21
|
+
"#{result.assertion_count} assert#{'s' if result.assertion_count != 1}, " \
|
22
|
+
"#{result.failure_count} fail#{'s' if result.failure_count != 1}, " \
|
23
|
+
"#{result.error_count} error#{'s' if result.error_count != 1}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def duration(duration, options={})
|
27
|
+
"Finished in #{round_float(duration)} seconds"
|
28
|
+
end
|
29
|
+
|
30
|
+
def round_float(float, decimals=4)
|
31
|
+
if Float.instance_method(:round).arity == 0 # Ruby 1.8
|
32
|
+
factor = 10**decimals
|
33
|
+
(float*factor).round / factor.to_f
|
34
|
+
else # Ruby 1.9
|
35
|
+
float.round(decimals)
|
36
|
+
end
|
37
|
+
end
|
15
38
|
end
|
16
39
|
|
17
40
|
end
|