rkh-autotest-growl 0.1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +41 -0
- data/Manifest.txt +23 -0
- data/PostInstall.txt +16 -0
- data/README.rdoc +180 -0
- data/Rakefile +26 -0
- data/autotest-growl.gemspec +55 -0
- data/growl/growlnotify +0 -0
- data/growl/growlnotify.com +0 -0
- data/img/error.png +0 -0
- data/img/failed.png +0 -0
- data/img/info.png +0 -0
- data/img/passed.png +0 -0
- data/img/pending.png +0 -0
- data/lib/autotest/growl.rb +168 -0
- data/lib/autotest/result.rb +64 -0
- data/lib/autotest-growl.rb +10 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/autotest-growl_spec.rb +80 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/rspec.rake +21 -0
- metadata +110 -0
data/History.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
== edge
|
2
|
+
|
3
|
+
* 1 minor improvement
|
4
|
+
* Reset the postinstall text color to previous (Konstantin Haase)
|
5
|
+
|
6
|
+
== 0.1.5 2009-07-27
|
7
|
+
|
8
|
+
* 1 major improvement
|
9
|
+
* More reliable growlnotify call
|
10
|
+
|
11
|
+
== 0.1.4 2009-07-23
|
12
|
+
|
13
|
+
* 1 major improvement
|
14
|
+
* Support for Windows (Karl O'Keeffe)
|
15
|
+
|
16
|
+
== 0.1.3 2009-07-22
|
17
|
+
|
18
|
+
* 1 major improvement
|
19
|
+
* Better result analysis and more readable notifications
|
20
|
+
* 3 minor improvement
|
21
|
+
* Move Cucumber notification to :ran_features hook (Karl O'Keeffe)
|
22
|
+
* Add one_notification_per_run configuration option
|
23
|
+
* Notification for undefined Cucumber scenarios/steps
|
24
|
+
|
25
|
+
== 0.1.2 2009-06-12
|
26
|
+
|
27
|
+
* 3 major improvements
|
28
|
+
* Add priorities to notifications (Michael Moen)
|
29
|
+
* Add clear_terminal configuration option (Michael Moen)
|
30
|
+
* Add show_modified_files configuration option (Graham Savage)
|
31
|
+
|
32
|
+
== 0.1.1 2009-06-02
|
33
|
+
|
34
|
+
* 1 major improvement
|
35
|
+
* Suppress Cucumber notification if not used
|
36
|
+
|
37
|
+
== 0.1.0 2009-05-28
|
38
|
+
|
39
|
+
* Initial release
|
40
|
+
* Growl notifications for Test::Unit, RSpec and Cucumber (workaround)
|
41
|
+
* Formerly part of autotest-mac which is now deprecated
|
data/Manifest.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
autotest-growl.gemspec
|
7
|
+
growl/growlnotify
|
8
|
+
growl/growlnotify.com
|
9
|
+
img/error.png
|
10
|
+
img/failed.png
|
11
|
+
img/info.png
|
12
|
+
img/passed.png
|
13
|
+
img/pending.png
|
14
|
+
lib/autotest-growl.rb
|
15
|
+
lib/autotest/growl.rb
|
16
|
+
lib/autotest/result.rb
|
17
|
+
script/console
|
18
|
+
script/destroy
|
19
|
+
script/generate
|
20
|
+
spec/autotest-growl_spec.rb
|
21
|
+
spec/spec.opts
|
22
|
+
spec/spec_helper.rb
|
23
|
+
tasks/rspec.rake
|
data/PostInstall.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
In order to use autotest-growl, the following line has to be added to your
|
2
|
+
~/.autotest file:
|
3
|
+
|
4
|
+
require 'autotest/growl'
|
5
|
+
|
6
|
+
Make sure Growl is installed on your computer. Download it from:
|
7
|
+
|
8
|
+
http://growl.info (Mac OS X)
|
9
|
+
http://growlforwindows.com (Windows)
|
10
|
+
|
11
|
+
If Growl notifications are not always displayed, take a look at the README
|
12
|
+
for assistance.
|
13
|
+
|
14
|
+
For more information, feedback and bug submissions, please visit:
|
15
|
+
|
16
|
+
http://www.bitcetera.com/products/autotest-growl
|
data/README.rdoc
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
= Autotest Growl
|
2
|
+
|
3
|
+
* Author: Sven Schwyn (http://www.bitcetera.com)
|
4
|
+
* Homepage: http://www.bitcetera.com/products/autotest-growl
|
5
|
+
* Issues and forum: https://forge.bitcetera.com/projects/show/autotest-growl
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
This gem aims to improve support for Growl notification by ZenTest's autotest.
|
10
|
+
It comes with a nice colored Ruby icon set and - for now - supports Cucumber
|
11
|
+
notifications by means of a workaround.
|
12
|
+
|
13
|
+
The priority of a notification is set according to the actual result so you
|
14
|
+
can configure Growl to style the notifications differently based on these
|
15
|
+
priorities:
|
16
|
+
|
17
|
+
* 2 for error or failed
|
18
|
+
* 0 for info
|
19
|
+
* -1 for pending, undefined or unknown
|
20
|
+
* -2 for passed
|
21
|
+
|
22
|
+
Furthermore the terminal running autotest is cleared on every cycle (unless
|
23
|
+
configured otherwise). Don't worry though, it's still possible to scroll up
|
24
|
+
to see the output of previous cycles - at least on the Terminal.app from
|
25
|
+
Apple.
|
26
|
+
|
27
|
+
=== Ruby 1.9.1 Note
|
28
|
+
|
29
|
+
For the moment, autotest growl doesn't seem to work on Ruby 1.9.1. Fixing this
|
30
|
+
might take a while though as autotest itself is currently misbehaving on Ruby
|
31
|
+
1.9 - at least on my setup.
|
32
|
+
|
33
|
+
== REQUIREMENTS:
|
34
|
+
|
35
|
+
* Growl >= 1.1.5 (Mac OS X) or >= 2.0b18 (Windows)
|
36
|
+
* ZenTest >= 4.1.3
|
37
|
+
|
38
|
+
== INSTALL:
|
39
|
+
|
40
|
+
First install the gem:
|
41
|
+
|
42
|
+
sudo gem install autotest-growl
|
43
|
+
|
44
|
+
Then add the following line to your ~/.autotest file:
|
45
|
+
|
46
|
+
require 'autotest/growl'
|
47
|
+
|
48
|
+
Make sure Growl is installed on your computer. You can download it from:
|
49
|
+
|
50
|
+
Mac OS X: http://growl.info
|
51
|
+
Windows: http://growlforwindows.com
|
52
|
+
|
53
|
+
== CONFIGURATION:
|
54
|
+
|
55
|
+
=== Custom Icons
|
56
|
+
|
57
|
+
Using your own set of icons is pretty simple. Just create a directory
|
58
|
+
~/.autotest-growl, copy your icons there and name them passed.png,
|
59
|
+
pending.png, failed.png, error.png and info.png.
|
60
|
+
|
61
|
+
=== Don't Clear the Terminal
|
62
|
+
|
63
|
+
Add the following to your ~/.autotest if you don't want the terminal to
|
64
|
+
be cleared before running a test:
|
65
|
+
|
66
|
+
Autotest::Growl::clear_terminal = false
|
67
|
+
|
68
|
+
=== Hide the Label
|
69
|
+
|
70
|
+
If you prefer the Growl notifications not to show labels such as "LABEL:
|
71
|
+
All tests have passed", add the following to your ~/.autotest:
|
72
|
+
|
73
|
+
Autotest::Growl::hide_label = true
|
74
|
+
|
75
|
+
=== One Notifications per Run
|
76
|
+
|
77
|
+
Allow only one test and one feature notification per run by adding the
|
78
|
+
following to your ~/.autotest:
|
79
|
+
|
80
|
+
Autotest::Growl::one_notification_per_run = true
|
81
|
+
|
82
|
+
=== Show Modified Files
|
83
|
+
|
84
|
+
Add the following to your ~/.autotest if you would like to receive a Growl
|
85
|
+
notification listing the files modified before tests are re-run.
|
86
|
+
|
87
|
+
Autotest::Growl::show_modified_files = true
|
88
|
+
|
89
|
+
== TROUBLESHOOTING:
|
90
|
+
|
91
|
+
=== Loading the Plugin Seems to Fail
|
92
|
+
|
93
|
+
Most likely you still have an old version of ZenTest <= 4.0.0 installed,
|
94
|
+
check it with:
|
95
|
+
|
96
|
+
gem list ZenTest
|
97
|
+
|
98
|
+
To uninstall a specific version (e.g. 4.0.0), type:
|
99
|
+
|
100
|
+
sudo gem uninstall ZenTest --version=4.0.0
|
101
|
+
|
102
|
+
Or remove all outdated versions of all installed gems:
|
103
|
+
|
104
|
+
sudo gem cleanup
|
105
|
+
|
106
|
+
=== Unreliable Growl Notifications on Mac OS X
|
107
|
+
|
108
|
+
Under some circumstances, Growl notifications seem to be swallowed randomly
|
109
|
+
on Mac OS X. If this happens to you, try the following.
|
110
|
+
|
111
|
+
Add this to your ~/.autotest:
|
112
|
+
|
113
|
+
Autotest::Growl::remote_notification = true
|
114
|
+
|
115
|
+
Now open "System Preferences -> Growl -> Network" and set the checkboxes
|
116
|
+
"Listen for incoming notifications" and "Allow remote application
|
117
|
+
registration”. Try whether remote notifications work with the following
|
118
|
+
test:
|
119
|
+
|
120
|
+
find /Library/Ruby /usr -name growlnotify -exec {} -H localhost -n autotest -m ok \;
|
121
|
+
|
122
|
+
If you get a NSPortTimeoutException, you should restart Growl and check
|
123
|
+
whether a firewall is blocking the connection. Once the notification is
|
124
|
+
displayed, go back to the System Preferences and disable the checkbox
|
125
|
+
"Allow remote application registration" again.
|
126
|
+
|
127
|
+
== DEVELOPMENT:
|
128
|
+
|
129
|
+
You can install the bleeding-edge version as follows:
|
130
|
+
|
131
|
+
sudo gem uninstall autotest-growl
|
132
|
+
sudo gem install svoop-autotest-growl --source http://gems.github.com
|
133
|
+
|
134
|
+
Bleeding-edge gems contains a fourth version digit group (e.g. the .8 in
|
135
|
+
0.1.5.8) to make sure Github builds the gem whenever new code is committed.
|
136
|
+
If there is no fourth version digit group, the edge version is identical
|
137
|
+
to the stable version from Rubyforge.
|
138
|
+
|
139
|
+
Please submit issues on:
|
140
|
+
|
141
|
+
https://forge.bitcetera.com/projects/show/autotest-growl
|
142
|
+
|
143
|
+
To contribute code, fork the project on Github, add your code and submit a
|
144
|
+
pull request:
|
145
|
+
|
146
|
+
http://github.com/guides/fork-a-project-and-submit-your-modifications
|
147
|
+
|
148
|
+
== CONTRIBUTIONS:
|
149
|
+
|
150
|
+
Thanks to the following folks who have contributed to this project:
|
151
|
+
|
152
|
+
* Michael Moen
|
153
|
+
* Graham Savage
|
154
|
+
* Karl O'Keeffe
|
155
|
+
* Konstantin Haase
|
156
|
+
|
157
|
+
== LICENSE:
|
158
|
+
|
159
|
+
(The MIT License)
|
160
|
+
|
161
|
+
Copyright (c) 2009 Sven Schwyn
|
162
|
+
|
163
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
164
|
+
a copy of this software and associated documentation files (the
|
165
|
+
'Software'), to deal in the Software without restriction, including
|
166
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
167
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
168
|
+
permit persons to whom the Software is furnished to do so, subject to
|
169
|
+
the following conditions:
|
170
|
+
|
171
|
+
The above copyright notice and this permission notice shall be
|
172
|
+
included in all copies or substantial portions of the Software.
|
173
|
+
|
174
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
175
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
176
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
177
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
178
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
179
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
180
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/autotest-growl'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
$hoe = Hoe.spec 'autotest-growl' do
|
12
|
+
self.developer 'Sven Schwyn', 'ruby@bitcetera.com'
|
13
|
+
self.summary = %q{Next generation Growl notification support for ZenTest's autotest.}
|
14
|
+
self.description = %q{This gem aims to improve support for Growl notification by ZenTest's autotest. It comes with a nice colored Ruby icon set and - for now - supports Cucumber by means of a workaround.}
|
15
|
+
self.url = %q{http://www.bitcetera.com/products/autotest-growl}
|
16
|
+
self.post_install_message = "\n\e[1;32m" + File.read('PostInstall.txt') + "\e[0m\n"
|
17
|
+
self.rubyforge_name = self.name
|
18
|
+
self.extra_deps = [
|
19
|
+
['ZenTest','>= 4.1.3'],
|
20
|
+
]
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'newgem/tasks'
|
24
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
25
|
+
|
26
|
+
task :default => [:spec]
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{autotest-growl}
|
5
|
+
s.version = "0.1.5.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Sven Schwyn"]
|
9
|
+
s.date = %q{2009-07-28}
|
10
|
+
s.description = %q{This gem aims to improve support for Growl notification by ZenTest's autotest. It comes with a nice colored Ruby icon set and - for now - supports Cucumber by means of a workaround.}
|
11
|
+
s.email = ["ruby@bitcetera.com"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt"]
|
13
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autotest-growl.gemspec", "growl/growlnotify", "growl/growlnotify.com", "img/error.png", "img/failed.png", "img/info.png", "img/passed.png", "img/pending.png", "lib/autotest-growl.rb", "lib/autotest/growl.rb", "lib/autotest/result.rb", "script/console", "script/destroy", "script/generate", "spec/autotest-growl_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
14
|
+
s.homepage = %q{http://www.bitcetera.com/products/autotest-growl}
|
15
|
+
s.post_install_message = %q{
|
16
|
+
[1;32mIn order to use autotest-growl, the following line has to be added to your
|
17
|
+
~/.autotest file:
|
18
|
+
|
19
|
+
require 'autotest/growl'
|
20
|
+
|
21
|
+
Make sure Growl is installed on your computer. Download it from:
|
22
|
+
|
23
|
+
http://growl.info (Mac OS X)
|
24
|
+
http://growlforwindows.com (Windows)
|
25
|
+
|
26
|
+
If Growl notifications are not always displayed, take a look at the README
|
27
|
+
for assistance.
|
28
|
+
|
29
|
+
For more information, feedback and bug submissions, please visit:
|
30
|
+
|
31
|
+
http://www.bitcetera.com/products/autotest-growl
|
32
|
+
[0m
|
33
|
+
}
|
34
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubyforge_project = %q{autotest-growl}
|
37
|
+
s.rubygems_version = %q{1.3.4}
|
38
|
+
s.summary = %q{Next generation Growl notification support for ZenTest's autotest.}
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<ZenTest>, [">= 4.1.3"])
|
46
|
+
s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<ZenTest>, [">= 4.1.3"])
|
49
|
+
s.add_dependency(%q<hoe>, [">= 2.3.2"])
|
50
|
+
end
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<ZenTest>, [">= 4.1.3"])
|
53
|
+
s.add_dependency(%q<hoe>, [">= 2.3.2"])
|
54
|
+
end
|
55
|
+
end
|
data/growl/growlnotify
ADDED
Binary file
|
Binary file
|
data/img/error.png
ADDED
Binary file
|
data/img/failed.png
ADDED
Binary file
|
data/img/info.png
ADDED
Binary file
|
data/img/passed.png
ADDED
Binary file
|
data/img/pending.png
ADDED
Binary file
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'autotest'
|
3
|
+
require File.join(File.dirname(__FILE__), 'result')
|
4
|
+
|
5
|
+
##
|
6
|
+
# Autotest::Growl
|
7
|
+
#
|
8
|
+
# == FEATUERS:
|
9
|
+
# * Display autotest results as local or remote Growl notifications.
|
10
|
+
# * Clean the terminal on every test cycle while maintaining scrollback.
|
11
|
+
#
|
12
|
+
# == SYNOPSIS:
|
13
|
+
# ~/.autotest
|
14
|
+
# require 'autotest/growl'
|
15
|
+
module Autotest::Growl
|
16
|
+
|
17
|
+
GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
18
|
+
|
19
|
+
@label = ''
|
20
|
+
@modified_files = []
|
21
|
+
@ran_tests = false
|
22
|
+
@ran_features = false
|
23
|
+
|
24
|
+
@@remote_notification = false
|
25
|
+
@@one_notification_per_run = false
|
26
|
+
@@clear_terminal = true
|
27
|
+
@@hide_label = false
|
28
|
+
@@show_modified_files = false
|
29
|
+
|
30
|
+
##
|
31
|
+
# Whether to use remote or local notificaton (default).
|
32
|
+
def self.remote_notification=(boolean)
|
33
|
+
@@remote_notification = boolean
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Whether to limit the number of notifications per run to one or not (default).
|
38
|
+
def self.one_notification_per_run=(boolean)
|
39
|
+
@@one_notification_per_run = boolean
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Whether to clear the terminal before running tests (default) or not.
|
44
|
+
def self.clear_terminal=(boolean)
|
45
|
+
@@clear_terminal = boolean
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Whether to display the label (default) or not.
|
50
|
+
def self.hide_label=(boolean)
|
51
|
+
@@hide_label = boolean
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Whether to display the modified files or not (default).
|
56
|
+
def self.show_modified_files=(boolean)
|
57
|
+
@@show_modified_files = boolean
|
58
|
+
end
|
59
|
+
|
60
|
+
##
|
61
|
+
# Display a message through Growl.
|
62
|
+
def self.growl(title, message, icon, priority=0, stick="")
|
63
|
+
growl = File.join(GEM_PATH, 'growl', 'growlnotify')
|
64
|
+
image = File.join(ENV['HOME'], '.autotest-growl', "#{icon}.png")
|
65
|
+
image = File.join(GEM_PATH, 'img', "#{icon}.png") unless File.exists?(image)
|
66
|
+
case RUBY_PLATFORM
|
67
|
+
when /mswin/
|
68
|
+
growl += '.com'
|
69
|
+
system %(#{growl} #{message.inspect} /a:"Autotest" /r:"Autotest" /n:"Autotest" /i:"#{image}" /p:#{priority} /t:"#{title}")
|
70
|
+
when /darwin/
|
71
|
+
if @@remote_notification
|
72
|
+
system %(#{growl} -H localhost -n Autotest --image '#{image}' -p #{priority} -m '#{message}' '#{title}' #{stick} &)
|
73
|
+
else
|
74
|
+
system %(#{growl} -w -n Autotest --image '#{image}' -p #{priority} -m '#{message}' '#{title}' #{stick} &)
|
75
|
+
end
|
76
|
+
else
|
77
|
+
raise "#{RUBY_PLATFORM} is not supported by autotest-growl"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Display the modified files.
|
83
|
+
Autotest.add_hook :updated do |autotest, modified|
|
84
|
+
@ran_tests = @ran_features = false
|
85
|
+
if @@show_modified_files
|
86
|
+
if modified != @last_modified
|
87
|
+
growl @label + 'Modifications detected.', modified.collect {|m| m[0]}.join(', '), 'info', 0
|
88
|
+
@last_modified = modified
|
89
|
+
end
|
90
|
+
end
|
91
|
+
false
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Set the label and clear the terminal.
|
96
|
+
Autotest.add_hook :run_command do
|
97
|
+
@label = File.basename(Dir.pwd).upcase + ': ' if !@@hide_label
|
98
|
+
print "\n"*2 + '-'*80 + "\n"*2
|
99
|
+
print "\e[2J\e[f" if @@clear_terminal
|
100
|
+
false
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Parse the RSpec and Test::Unit results and send them to Growl.
|
105
|
+
Autotest.add_hook :ran_command do |autotest|
|
106
|
+
unless @@one_notification_per_run && @ran_tests
|
107
|
+
result = Result.new(autotest)
|
108
|
+
if result.exists?
|
109
|
+
case result.framework
|
110
|
+
when 'test-unit'
|
111
|
+
if result.has?('test-error')
|
112
|
+
growl @label + 'Cannot run some unit tests.', "#{result.get('test-error')} in #{result.get('test')}", 'error', 2
|
113
|
+
elsif result.has?('test-failed')
|
114
|
+
growl @label + 'Some unit tests failed.', "#{result['test-failed']} of #{result.get('test-assertion')} in #{result.get('test')} failed", 'failed', 2
|
115
|
+
else
|
116
|
+
growl @label + 'All unit tests passed.', "#{result.get('test-assertion')} in #{result.get('test')}", 'passed', -2
|
117
|
+
end
|
118
|
+
when 'rspec'
|
119
|
+
if result.has?('example-failed')
|
120
|
+
growl @label + 'Some RSpec examples failed.', "#{result['example-failed']} of #{result.get('example')} failed", 'failed', 2
|
121
|
+
elsif result.has?('example-pending')
|
122
|
+
growl @label + 'Some RSpec examples are pending.', "#{result['example-pending']} of #{result.get('example')} pending", 'pending', -1
|
123
|
+
else
|
124
|
+
growl @label + 'All RSpec examples passed.', "#{result.get('example')}", 'passed', -2
|
125
|
+
end
|
126
|
+
end
|
127
|
+
else
|
128
|
+
growl @label + 'Could not run tests.', '', 'error', 2
|
129
|
+
end
|
130
|
+
@ran_test = true
|
131
|
+
end
|
132
|
+
false
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Parse the Cucumber results and sent them to Growl.
|
137
|
+
Autotest.add_hook :ran_features do |autotest|
|
138
|
+
unless @@one_notification_per_run && @ran_features
|
139
|
+
result = Result.new(autotest)
|
140
|
+
if result.exists?
|
141
|
+
case result.framework
|
142
|
+
when 'cucumber'
|
143
|
+
explanation = []
|
144
|
+
if result.has?('scenario-undefined') || result.has?('step-undefined')
|
145
|
+
explanation << "#{result['scenario-undefined']} of #{result.get('scenario')} not defined" if result['scenario-undefined']
|
146
|
+
explanation << "#{result['step-undefined']} of #{result.get('step')} not defined" if result['step-undefined']
|
147
|
+
growl @label + 'Some Cucumber scenarios are not defined.', "#{explanation.join("\n")}", 'pending', -1
|
148
|
+
elsif result.has?('scenario-failed') || result.has?('step-failed')
|
149
|
+
explanation << "#{result['scenario-failed']} of #{result.get('scenario')} failed" if result['scenario-failed']
|
150
|
+
explanation << "#{result['step-failed']} of #{result.get('step')} failed" if result['step-failed']
|
151
|
+
growl @label + 'Some Cucumber scenarios failed.', "#{explanation.join("\n")}", 'failed', 2
|
152
|
+
elsif result.has?('scenario-pending') || result.has?('step-pending')
|
153
|
+
explanation << "#{result['scenario-pending']} of #{result.get('scenario')} pending" if result['scenario-pending']
|
154
|
+
explanation << "#{result['step-pending']} of #{result.get('step')} pending" if result['step-pending']
|
155
|
+
growl @label + 'Some Cucumber scenarios are pending.', "#{explanation.join("\n")}", 'pending', -1
|
156
|
+
else
|
157
|
+
growl @label + 'All Cucumber features passed.', '', 'passed', -2
|
158
|
+
end
|
159
|
+
end
|
160
|
+
else
|
161
|
+
growl @label + 'Could not run features.', '', 'error', 2
|
162
|
+
end
|
163
|
+
@ran_features = true
|
164
|
+
end
|
165
|
+
false
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Result
|
2
|
+
|
3
|
+
##
|
4
|
+
# Analyze test result lines and return the numbers in a hash.
|
5
|
+
def initialize(autotest)
|
6
|
+
@numbers = {}
|
7
|
+
lines = autotest.results.map {|s| s.gsub(/(\e.*?m|\n)/, '') } # remove escape sequences
|
8
|
+
lines.reject! {|line| !line.match(/\d+\s+(example|test|scenario|step)s?/) } # isolate result numbers
|
9
|
+
lines.each do |line|
|
10
|
+
prefix = nil
|
11
|
+
line.scan(/([1-9]\d*)\s(\w+)/) do |number, kind|
|
12
|
+
kind.sub!(/s$/, '') # singularize
|
13
|
+
kind.sub!(/failure/, 'failed') # homogenize
|
14
|
+
if prefix
|
15
|
+
@numbers["#{prefix}-#{kind}"] = number.to_i
|
16
|
+
else
|
17
|
+
@numbers[kind] = number.to_i
|
18
|
+
prefix = kind
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Determine the testing framework used.
|
26
|
+
def framework
|
27
|
+
case
|
28
|
+
when @numbers['test']: 'test-unit'
|
29
|
+
when @numbers['example']: 'rspec'
|
30
|
+
when @numbers['scenario']: 'cucumber'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Determine whether a result exists at all.
|
36
|
+
def exists?
|
37
|
+
!@numbers.empty?
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Check whether a specific result is present.
|
42
|
+
def has?(kind)
|
43
|
+
@numbers.has_key?(kind)
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Get a plain result number.
|
48
|
+
def [](kind)
|
49
|
+
@numbers[kind]
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Get a labelled result number. The prefix is removed and the label pluralized if necessary.
|
54
|
+
def get(kind)
|
55
|
+
"#{@numbers[kind]} #{kind.sub(/^.*-/, '')}#{'s' if @numbers[kind] != 1 && !kind.match(/(ed|ing)$/)}" if @numbers[kind]
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Get the fatal error if any.
|
60
|
+
def fatal_error
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require File.join(File.dirname(__FILE__), 'autotest', 'growl')
|
5
|
+
|
6
|
+
module AutotestGrowl
|
7
|
+
|
8
|
+
VERSION = '0.1.5.1'
|
9
|
+
|
10
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/testli.rb'}"
|
9
|
+
puts "Loading testli gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "handling results" do
|
4
|
+
before do
|
5
|
+
@autotest = Autotest.new
|
6
|
+
@autotest.hook(:updated)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "for RSpec" do
|
10
|
+
it "should show a 'passed' notification" do
|
11
|
+
Autotest::Growl.should_receive(:growl).and_return('passed')
|
12
|
+
@autotest.results = ["10 examples, 0 failures"]
|
13
|
+
@autotest.hook(:ran_command)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should show a 'failed' notification" do
|
17
|
+
Autotest::Growl.should_receive(:growl).and_return('failed')
|
18
|
+
@autotest.results = ["10 examples, 1 failures"]
|
19
|
+
@autotest.hook(:ran_command)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should show a 'pending' notification" do
|
23
|
+
Autotest::Growl.should_receive(:growl).and_return('pending')
|
24
|
+
@autotest.results = ["10 examples, 0 failures, 1 pending"]
|
25
|
+
@autotest.hook(:ran_command)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should show an 'error' notification" do
|
29
|
+
Autotest::Growl.should_receive(:growl).and_return('error')
|
30
|
+
@autotest.results = []
|
31
|
+
@autotest.hook(:ran_command)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "for Test::Unit" do
|
36
|
+
it "should show a 'passed' notification" do
|
37
|
+
Autotest::Growl.should_receive(:growl).and_return('passed')
|
38
|
+
@autotest.results = ["1 tests, 1 assertions, 0 failures, 0 errors"]
|
39
|
+
@autotest.hook(:ran_command)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should show a 'failed' notification" do
|
43
|
+
Autotest::Growl.should_receive(:growl).and_return('failed')
|
44
|
+
@autotest.results = ["1 tests, 1 assertions, 1 failures, 0 errors"]
|
45
|
+
@autotest.hook(:ran_command)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should show an 'error' notification" do
|
49
|
+
Autotest::Growl.should_receive(:growl).and_return('error')
|
50
|
+
@autotest.results = ["1 tests, 1 assertions, 0 failures, 1 errors"]
|
51
|
+
@autotest.hook(:ran_command)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "for Cucumber" do
|
56
|
+
it "should show a 'passed' notification" do
|
57
|
+
Autotest::Growl.should_receive(:growl).and_return('passed')
|
58
|
+
@autotest.results = ["1 scenario (1 passed)", "1 step (1 passed)"]
|
59
|
+
@autotest.hook(:ran_features)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should show a 'failed' notification" do
|
63
|
+
Autotest::Growl.should_receive(:growl).and_return('failed')
|
64
|
+
@autotest.results = ["2 scenarios (1 failed, 1 passed)", "2 steps (1 failed, 1 passed)"]
|
65
|
+
@autotest.hook(:ran_features)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should show a 'pending' notification" do
|
69
|
+
Autotest::Growl.should_receive(:growl).and_return('pending')
|
70
|
+
@autotest.results = ["2 scenarios (1 undefined, 1 passed)", "2 steps (1 undefined, 1 passed)"]
|
71
|
+
@autotest.hook(:ran_features)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should show an 'error' notification" do
|
75
|
+
Autotest::Growl.should_receive(:growl).and_return('error')
|
76
|
+
@autotest.results = []
|
77
|
+
@autotest.hook(:ran_features)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
gem 'rspec'
|
6
|
+
require 'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
+
require 'autotest/growl'
|
11
|
+
|
12
|
+
module Autotest::Growl
|
13
|
+
def self.growl(title, message, icon, priority=0, stick="")
|
14
|
+
icon
|
15
|
+
end
|
16
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rkh-autotest-growl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sven Schwyn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-28 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ZenTest
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 4.1.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.2
|
34
|
+
version:
|
35
|
+
description: This gem aims to improve support for Growl notification by ZenTest's autotest. It comes with a nice colored Ruby icon set and - for now - supports Cucumber by means of a workaround.
|
36
|
+
email:
|
37
|
+
- ruby@bitcetera.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
- PostInstall.txt
|
46
|
+
files:
|
47
|
+
- History.txt
|
48
|
+
- Manifest.txt
|
49
|
+
- PostInstall.txt
|
50
|
+
- README.rdoc
|
51
|
+
- Rakefile
|
52
|
+
- autotest-growl.gemspec
|
53
|
+
- growl/growlnotify
|
54
|
+
- growl/growlnotify.com
|
55
|
+
- img/error.png
|
56
|
+
- img/failed.png
|
57
|
+
- img/info.png
|
58
|
+
- img/passed.png
|
59
|
+
- img/pending.png
|
60
|
+
- lib/autotest-growl.rb
|
61
|
+
- lib/autotest/growl.rb
|
62
|
+
- lib/autotest/result.rb
|
63
|
+
- script/console
|
64
|
+
- script/destroy
|
65
|
+
- script/generate
|
66
|
+
- spec/autotest-growl_spec.rb
|
67
|
+
- spec/spec.opts
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- tasks/rspec.rake
|
70
|
+
has_rdoc: false
|
71
|
+
homepage: http://www.bitcetera.com/products/autotest-growl
|
72
|
+
licenses:
|
73
|
+
post_install_message: "\n\
|
74
|
+
\e[1;32mIn order to use autotest-growl, the following line has to be added to your\n\
|
75
|
+
~/.autotest file:\n\n\
|
76
|
+
require 'autotest/growl'\n\n\
|
77
|
+
Make sure Growl is installed on your computer. Download it from:\n\n\
|
78
|
+
http://growl.info (Mac OS X)\n\
|
79
|
+
http://growlforwindows.com (Windows)\n\n\
|
80
|
+
If Growl notifications are not always displayed, take a look at the README\n\
|
81
|
+
for assistance.\n\n\
|
82
|
+
For more information, feedback and bug submissions, please visit:\n\n\
|
83
|
+
http://www.bitcetera.com/products/autotest-growl\n\
|
84
|
+
\e[0m\n"
|
85
|
+
rdoc_options:
|
86
|
+
- --main
|
87
|
+
- README.rdoc
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project: autotest-growl
|
105
|
+
rubygems_version: 1.3.5
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: Next generation Growl notification support for ZenTest's autotest.
|
109
|
+
test_files: []
|
110
|
+
|