test_notifier 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -2
- data/Manifest.txt +3 -0
- data/README.txt +5 -0
- data/lib/test_notifier.rb +73 -48
- data/lib/test_notifier/autotest.rb +7 -0
- data/lib/test_notifier/rspec.rb +23 -0
- data/lib/test_notifier/test_unit.rb +20 -0
- data/lib/test_notifier/version.rb +1 -1
- metadata +49 -39
data/History.txt
CHANGED
@@ -15,6 +15,10 @@
|
|
15
15
|
|
16
16
|
* title was displayed incorrectly on growlnotify
|
17
17
|
|
18
|
-
== 0.0.5 2007-
|
18
|
+
== 0.0.5 2007-10-18
|
19
19
|
|
20
|
-
*
|
20
|
+
* bug fix
|
21
|
+
|
22
|
+
== 0.0.6 2008-01-14
|
23
|
+
|
24
|
+
* added support for both Test::Unit and RSpec, with or without Autotest
|
data/Manifest.txt
CHANGED
@@ -6,6 +6,9 @@ Rakefile
|
|
6
6
|
config/hoe.rb
|
7
7
|
config/requirements.rb
|
8
8
|
lib/test_notifier.rb
|
9
|
+
lib/test_notifier/test_unit.rb
|
10
|
+
lib/test_notifier/autotest.rb
|
11
|
+
lib/test_notifier/rspec.rb
|
9
12
|
lib/test_notifier/icons/error.png
|
10
13
|
lib/test_notifier/icons/failure.png
|
11
14
|
lib/test_notifier/icons/passed.png
|
data/README.txt
CHANGED
@@ -34,6 +34,11 @@ Windows
|
|
34
34
|
2) Install ruby-snarl:
|
35
35
|
gem install ruby-snarl
|
36
36
|
|
37
|
+
Usage
|
38
|
+
-----
|
39
|
+
If you're using Test::Unit you should add `require "test_notifier/test_unit"`
|
40
|
+
If you're using RSpec you should add `require "test_notifier/rspec"`
|
41
|
+
If you're using Autotest you should add `require "test_notifier/autotest"` to the file `~/.autotest`
|
37
42
|
|
38
43
|
--
|
39
44
|
Found this useful? Consider a donation (any amount):
|
data/lib/test_notifier.rb
CHANGED
@@ -1,53 +1,78 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
2
|
-
|
3
1
|
require 'snarl' if RUBY_PLATFORM =~ /mswin/
|
4
|
-
require 'test/unit/ui/console/testrunner'
|
5
2
|
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
3
|
+
module TestNotifier
|
4
|
+
# create a .test_notifier at your home
|
5
|
+
# directory and save the images as passed.png,
|
6
|
+
# failure.png and error.png for custom images
|
7
|
+
PASSED_IMAGE = "passed.png"
|
8
|
+
FAILURE_IMAGE = "failure.png"
|
9
|
+
ERROR_IMAGE = "error.png"
|
10
|
+
FAILURE_TITLE = "FAILED"
|
11
|
+
PASSED_TITLE = "Passed"
|
12
|
+
|
13
|
+
RSPEC_REGEX = /(\d+) examples?, (\d+) failures?(, (\d+) pendings?)?/
|
14
|
+
TEST_UNIT_REGEX = /(\d+)\stests,\s(\d+)\sassertions,\s(\d+)\sfailures,\s(\d+)\serrors/
|
15
|
+
|
16
|
+
def self.notify(image, title, message)
|
17
|
+
image ||= "none.png"
|
18
|
+
|
19
|
+
custom_image = File.join(File.expand_path("~/.test_notifier"), "image", image)
|
20
|
+
image = File.exists?(custom_image) ? custom_image : File.join(File.dirname(__FILE__), "test_notifier", "icons", image)
|
21
|
+
|
22
|
+
if RUBY_PLATFORM =~ /darwin/
|
23
|
+
system("growlnotify -n test_notifier --image #{image} -p 2 -m \"#{message}\" -t \"#{title}\"")
|
24
|
+
elsif RUBY_PLATFORM =~ /mswin/
|
25
|
+
Snarl.show_message(title, message, image)
|
26
|
+
elsif RUBY_PLATFORM =~ /linux/
|
27
|
+
system("notify-send -i #{image} #{title} \"#{message}\"")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.rspec?(content)
|
32
|
+
(RSPEC_REGEX =~ content)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.notification_for_rspec(content)
|
36
|
+
matches, *output = *content.to_s.match(RSPEC_REGEX)
|
37
|
+
output = output.map {|i| i.to_i }
|
38
|
+
e, f, none, p = output
|
39
|
+
|
40
|
+
if f > 0
|
41
|
+
# test has failed
|
42
|
+
title = FAILURE_TITLE
|
43
|
+
image = FAILURE_IMAGE
|
44
|
+
elsif e > 0
|
45
|
+
# everything's ok
|
46
|
+
title = PASSED_TITLE
|
47
|
+
image = PASSED_IMAGE
|
48
|
+
else
|
49
|
+
# no examples
|
50
|
+
return
|
51
|
+
end
|
52
|
+
|
53
|
+
message = "#{e} examples, #{f} failures, #{p} pending"
|
54
|
+
notify(image, title, message)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.notification_for_test_unit(content)
|
58
|
+
matches, *output = *content.to_s.match(TEST_UNIT_REGEX)
|
59
|
+
output = output.map {|i| i.to_i }
|
60
|
+
t, a, f, e = output
|
61
|
+
|
62
|
+
if f > 0 || e > 0
|
63
|
+
# test has failed or raised an error
|
64
|
+
title = FAILURE_TITLE
|
65
|
+
image = e > 0 ? ERROR_IMAGE : FAILURE_IMAGE
|
66
|
+
elsif a > 0
|
67
|
+
# everything's ok
|
68
|
+
title = PASSED_TITLE
|
69
|
+
image = PASSED_IMAGE
|
70
|
+
else
|
71
|
+
# no assertions
|
72
|
+
return
|
51
73
|
end
|
74
|
+
|
75
|
+
message = "#{t} tests, #{a} assertions, #{f} failures, #{e} errors"
|
76
|
+
notify(image, title, message)
|
52
77
|
end
|
53
78
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_notifier'
|
2
|
+
require 'spec/runner/formatter/base_text_formatter'
|
3
|
+
|
4
|
+
class Spec::Runner::Formatter::BaseTextFormatter
|
5
|
+
alias dump_summary_original dump_summary
|
6
|
+
|
7
|
+
def dump_summary(duration, examples, failed, pending)
|
8
|
+
dump_summary_original(duration, examples, failed, pending)
|
9
|
+
|
10
|
+
return if examples == 0
|
11
|
+
|
12
|
+
if failed > 0
|
13
|
+
title = TestNotifier::FAILURE_TITLE
|
14
|
+
image = TestNotifier::ERROR_IMAGE
|
15
|
+
else
|
16
|
+
title = TestNotifier::PASSED_TITLE
|
17
|
+
image = TestNotifier::PASSED_IMAGE
|
18
|
+
end
|
19
|
+
|
20
|
+
message = "#{examples} examples, #{failed} failed, #{pending} pending"
|
21
|
+
TestNotifier::notify(image, title, message)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_notifier'
|
2
|
+
require 'test/unit/ui/console/testrunner'
|
3
|
+
|
4
|
+
module Test
|
5
|
+
module Unit
|
6
|
+
module UI
|
7
|
+
module Console
|
8
|
+
class TestRunner
|
9
|
+
alias finished_original finished
|
10
|
+
|
11
|
+
def finished(elapsed_time)
|
12
|
+
finished_original(elapsed_time)
|
13
|
+
content = @result.to_s
|
14
|
+
TestNotifier::notification_for_test_unit(content)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,33 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: test_notifier
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-11-08 00:00:00 -02:00
|
8
|
-
summary: Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps.
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: fnando.vieira@gmail.com
|
12
|
-
homepage: http://testnotifier.rubyforge.org
|
13
|
-
rubyforge_project: testnotifier
|
14
|
-
description: Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps.
|
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:
|
4
|
+
version: 0.0.6
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Nando Vieira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-01-16 00:00:00 -02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps.
|
17
|
+
email: fnando.vieira@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- History.txt
|
24
|
+
- License.txt
|
25
|
+
- Manifest.txt
|
26
|
+
- README.txt
|
27
|
+
- website/index.txt
|
31
28
|
files:
|
32
29
|
- History.txt
|
33
30
|
- License.txt
|
@@ -37,6 +34,9 @@ files:
|
|
37
34
|
- config/hoe.rb
|
38
35
|
- config/requirements.rb
|
39
36
|
- lib/test_notifier.rb
|
37
|
+
- lib/test_notifier/test_unit.rb
|
38
|
+
- lib/test_notifier/autotest.rb
|
39
|
+
- lib/test_notifier/rspec.rb
|
40
40
|
- lib/test_notifier/icons/error.png
|
41
41
|
- lib/test_notifier/icons/failure.png
|
42
42
|
- lib/test_notifier/icons/passed.png
|
@@ -56,23 +56,33 @@ files:
|
|
56
56
|
- website/javascripts/rounded_corners_lite.inc.js
|
57
57
|
- website/stylesheets/screen.css
|
58
58
|
- website/template.rhtml
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://testnotifier.rubyforge.org
|
61
|
+
post_install_message:
|
62
62
|
rdoc_options:
|
63
63
|
- --main
|
64
64
|
- README.txt
|
65
|
-
|
66
|
-
-
|
67
|
-
|
68
|
-
|
69
|
-
-
|
70
|
-
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: "0"
|
78
|
+
version:
|
75
79
|
requirements: []
|
76
80
|
|
77
|
-
|
78
|
-
|
81
|
+
rubyforge_project: testnotifier
|
82
|
+
rubygems_version: 1.0.1
|
83
|
+
signing_key:
|
84
|
+
specification_version: 2
|
85
|
+
summary: Display system notifications (dbus, growl and snarl) after running tests. It works on Mac OS X, Linux and Windows. Powerful when used with Autotest ZenTest gem for Rails apps.
|
86
|
+
test_files:
|
87
|
+
- test/test_helper.rb
|
88
|
+
- test/test_test_notifier.rb
|