svoop-autotest-growl 0.1.1 → 0.1.4

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.
data/History.txt CHANGED
@@ -1,3 +1,24 @@
1
+ == 0.1.4 2009-07-23
2
+
3
+ * 1 major improvement
4
+ * Support for Windows (Karl O'Keeffe)
5
+
6
+ == 0.1.3 2009-07-22
7
+
8
+ * 1 major improvement
9
+ * Better result analysis and more readable notifications
10
+ * 3 minor improvement
11
+ * Move Cucumber notification to :ran_features hook (Karl O'Keeffe)
12
+ * Add one_notification_per_run configuration option
13
+ * Notification for undefined Cucumber scenarios/steps
14
+
15
+ == 0.1.2 2009-06-12
16
+
17
+ * 3 major improvements
18
+ * Add priorities to notifications (Michael Moen)
19
+ * Add clear_terminal configuration option (Michael Moen)
20
+ * Add show_modified_files configuration option (Graham Savage)
21
+
1
22
  == 0.1.1 2009-06-02
2
23
 
3
24
  * 1 major improvement
data/Manifest.txt CHANGED
@@ -5,12 +5,16 @@ README.rdoc
5
5
  Rakefile
6
6
  autotest-growl.gemspec
7
7
  growl/growlnotify
8
+ growl/growlnotify.com
9
+ growl/growlnotify.exe
8
10
  img/error.png
9
11
  img/failed.png
12
+ img/info.png
10
13
  img/passed.png
11
14
  img/pending.png
12
15
  lib/autotest-growl.rb
13
16
  lib/autotest/growl.rb
17
+ lib/autotest/result.rb
14
18
  script/console
15
19
  script/destroy
16
20
  script/generate
data/PostInstall.txt CHANGED
@@ -5,7 +5,8 @@ require 'autotest/growl'
5
5
 
6
6
  Make sure Growl is installed on your computer. Download it from:
7
7
 
8
- http://growl.info
8
+ http://growl.info (Mac OS X)
9
+ http://growlforwindows.com (Windows)
9
10
 
10
11
  If Growl notifications are not always displayed, take a look at the README
11
12
  for assistance.
@@ -19,5 +20,5 @@ http://www.bitcetera.com/products/autotest-growl
19
20
  | ZenTest no longer comes with bundled Growl support and therefore the |
20
21
  | require in your ~/.autotest must not contain the absolute path to this |
21
22
  | gem anymore. Please update your ~/.autotest to contain the require line |
22
- | mentioned above. |
23
+ | mentioned above. Make sure no ZenTest version <=4.0.0 is installed. |
23
24
  +-------------------------------------------------------------------------+
data/README.rdoc CHANGED
@@ -1,5 +1,6 @@
1
1
  = Autotest Growl
2
2
 
3
+ * Author: Sven Schwyn (http://www.bitcetera.com)
3
4
  * Homepage: http://www.bitcetera.com/products/autotest-growl
4
5
  * Issues and forum: https://forge.bitcetera.com/projects/show/autotest-growl
5
6
 
@@ -9,9 +10,19 @@ This gem aims to improve support for Growl notification by ZenTest's autotest.
9
10
  It comes with a nice colored Ruby icon set and - for now - supports Cucumber
10
11
  notifications by means of a workaround.
11
12
 
12
- Furthermore the terminal running autotest is cleared on every cycle. Don't
13
- worry though, it's still possible to scroll up to see the output of previous
14
- cycles.
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.
15
26
 
16
27
  === Ruby 1.9.1 Note
17
28
 
@@ -21,8 +32,8 @@ might take a while though as autotest itself is currently misbehaving on Ruby
21
32
 
22
33
  == REQUIREMENTS:
23
34
 
24
- * Growl >= 1.1.4
25
- * ZenTest >= 4.1.0
35
+ * Growl >= 1.1.5 (Mac OS X) or >= 2.0b18 (Windows)
36
+ * ZenTest >= 4.1.3
26
37
 
27
38
  == INSTALL:
28
39
 
@@ -36,7 +47,8 @@ Then add the following line to your ~/.autotest file:
36
47
 
37
48
  Make sure Growl is installed on your computer. You can download it from:
38
49
 
39
- http://growl.info
50
+ Mac OS X: http://growl.info
51
+ Windows: http://growlforwindows.com
40
52
 
41
53
  == CONFIGURATION:
42
54
 
@@ -44,7 +56,14 @@ http://growl.info
44
56
 
45
57
  Using your own set of icons is pretty simple. Just create a directory
46
58
  ~/.autotest-growl, copy your icons there and name them passed.png,
47
- pending.png, failed.png and error.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
48
67
 
49
68
  === Hide the Label
50
69
 
@@ -53,18 +72,41 @@ All tests have passed", add the following to your ~/.autotest:
53
72
 
54
73
  Autotest::Growl::hide_label = true
55
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
+
56
89
  == TROUBLESHOOTING:
57
90
 
58
- === Missing Cucumber Notifications
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
59
101
 
60
- If you are using autotest-fsevent as well, the require statements are not
61
- ordered correctly. The require for autotest-fsevent must come after all
62
- other requires in your ~/.autotest.
102
+ Or remove all outdated versions of all installed gems:
63
103
 
64
- === Unreliable Growl Notifications
104
+ sudo gem cleanup
65
105
 
66
- Under some circumstances, Growl notifications seem to be swallowed randomly.
67
- If this happens to you, try the following.
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.
68
110
 
69
111
  Add this to your ~/.autotest:
70
112
 
@@ -98,6 +140,14 @@ pull request:
98
140
 
99
141
  http://github.com/guides/fork-a-project-and-submit-your-modifications
100
142
 
143
+ == CONTRIBUTIONS:
144
+
145
+ Thanks to the following folks who have contributed to this project:
146
+
147
+ * Michael Moen
148
+ * Graham Savage
149
+ * Karl O'Keeffe
150
+
101
151
  == LICENSE:
102
152
 
103
153
  (The MIT License)
data/Rakefile CHANGED
@@ -1,27 +1,27 @@
1
- require 'rubygems' unless ENV['NO_RUBYGEMS']
2
- %w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
- require File.dirname(__FILE__) + '/lib/autotest-growl'
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/autotest-growl'
4
6
 
5
- $hoe = Hoe.new('autotest-growl', AutotestGrowl::VERSION) do |p|
6
- p.developer('Sven Schwyn', 'ruby@bitcetera.com')
7
- p.summary = %q{Next generation Growl notification support for ZenTest's autotest.}
8
- p.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.}
9
- p.url = %q{http://www.bitcetera.com/products/autotest-growl}
10
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
11
- p.post_install_message = "\n\e[1;32m" + File.read('PostInstall.txt') + "\e[0;30m\n"
12
- p.rubyforge_name = p.name
13
- p.extra_deps = [
14
- ['ZenTest','>= 4.1.0'],
15
- ]
16
- p.extra_dev_deps = [
17
- ['newgem', ">= #{::Newgem::VERSION}"]
18
- ]
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
19
10
 
20
- p.clean_globs |= %w[**/.DS_Store tmp *.log]
21
- path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
22
- p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
23
- p.rsync_args = '-av --delete --ignore-errors'
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.changes = self.paragraphs_of("History.txt", 0..1).join("\n\n")
17
+ self.post_install_message = "\n\e[1;32m" + File.read('PostInstall.txt') + "\e[0;30m\n"
18
+ self.rubyforge_name = self.name
19
+ self.extra_deps = [
20
+ ['ZenTest','>= 4.1.3'],
21
+ ]
24
22
  end
25
23
 
26
24
  require 'newgem/tasks'
27
25
  Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ task :default => [:spec]
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{autotest-growl}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sven Schwyn"]
9
- s.date = %q{2009-06-03}
9
+ s.date = %q{2009-07-23}
10
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
11
  s.email = ["ruby@bitcetera.com"]
12
- s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
13
- s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autotest-growl.gemspec", "growl/growlnotify", "img/error.png", "img/failed.png", "img/passed.png", "img/pending.png", "lib/autotest-growl.rb", "lib/autotest/growl.rb", "script/console", "script/destroy", "script/generate", "spec/autotest-growl_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
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", "growl/growlnotify.exe", "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
14
  s.homepage = %q{http://www.bitcetera.com/products/autotest-growl}
15
15
  s.post_install_message = %q{
16
16
  In order to use autotest-growl, the following line has to be added to your
@@ -34,14 +34,14 @@ http://www.bitcetera.com/products/autotest-growl
34
34
  | ZenTest no longer comes with bundled Growl support and therefore the |
35
35
  | require in your ~/.autotest must not contain the absolute path to this |
36
36
  | gem anymore. Please update your ~/.autotest to contain the require line |
37
- | mentioned above. |
37
+ | mentioned above. Make sure no ZenTest version <=4.0.0 is installed. |
38
38
  +-------------------------------------------------------------------------+
39
39
  
40
40
  }
41
41
  s.rdoc_options = ["--main", "README.rdoc"]
42
42
  s.require_paths = ["lib"]
43
43
  s.rubyforge_project = %q{autotest-growl}
44
- s.rubygems_version = %q{1.3.3}
44
+ s.rubygems_version = %q{1.3.4}
45
45
  s.summary = %q{Next generation Growl notification support for ZenTest's autotest.}
46
46
 
47
47
  if s.respond_to? :specification_version then
@@ -49,17 +49,14 @@ http://www.bitcetera.com/products/autotest-growl
49
49
  s.specification_version = 3
50
50
 
51
51
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
- s.add_runtime_dependency(%q<ZenTest>, [">= 4.1.0"])
53
- s.add_development_dependency(%q<newgem>, [">= 1.4.1"])
54
- s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
52
+ s.add_runtime_dependency(%q<ZenTest>, [">= 4.1.3"])
53
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
55
54
  else
56
- s.add_dependency(%q<ZenTest>, [">= 4.1.0"])
57
- s.add_dependency(%q<newgem>, [">= 1.4.1"])
58
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
55
+ s.add_dependency(%q<ZenTest>, [">= 4.1.3"])
56
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
59
57
  end
60
58
  else
61
- s.add_dependency(%q<ZenTest>, [">= 4.1.0"])
62
- s.add_dependency(%q<newgem>, [">= 1.4.1"])
63
- s.add_dependency(%q<hoe>, [">= 1.8.0"])
59
+ s.add_dependency(%q<ZenTest>, [">= 4.1.3"])
60
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
64
61
  end
65
62
  end
data/growl/growlnotify CHANGED
Binary file
Binary file
Binary file
data/img/info.png ADDED
Binary file
@@ -1,5 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'autotest'
3
+ require File.join(File.dirname(__FILE__), 'result')
3
4
 
4
5
  ##
5
6
  # Autotest::Growl
@@ -13,10 +14,18 @@ require 'autotest'
13
14
  # require 'autotest/growl'
14
15
  module Autotest::Growl
15
16
 
16
- GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
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
17
23
 
18
24
  @@remote_notification = false
25
+ @@one_notification_per_run = false
26
+ @@clear_terminal = true
19
27
  @@hide_label = false
28
+ @@show_modified_files = false
20
29
 
21
30
  ##
22
31
  # Whether to use remote or local notificaton (default).
@@ -24,70 +33,134 @@ module Autotest::Growl
24
33
  @@remote_notification = boolean
25
34
  end
26
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
+
27
48
  ##
28
49
  # Whether to display the label (default) or not.
29
50
  def self.hide_label=(boolean)
30
51
  @@hide_label = boolean
31
52
  end
32
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
+
33
60
  ##
34
61
  # Display a message through Growl.
35
- def self.growl title, message, icon, priority=0, stick=""
62
+ def self.growl(title, message, icon, priority=0, stick="")
36
63
  growl = File.join(GEM_PATH, 'growl', 'growlnotify')
37
64
  image = File.join(ENV['HOME'], '.autotest-growl', "#{icon}.png")
38
65
  image = File.join(GEM_PATH, 'img', "#{icon}.png") unless File.exists?(image)
39
- if @@remote_notification
40
- system "#{growl} -H localhost -n autotest --image '#{image}' -p #{priority} -m #{message.inspect} '#{title}' #{stick}"
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} -n autotest --image '#{image}' -p #{priority} -m '#{message}' '#{title}' #{stick})
75
+ end
41
76
  else
42
- system "#{growl} -n autotest --image '#{image}' -p #{priority} -m #{message.inspect} '#{title}' #{stick}"
77
+ raise "#{RUBY_PLATFORM} is not supported by autotest-growl"
43
78
  end
44
79
  end
45
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
+
46
94
  ##
47
95
  # Set the label and clear the terminal.
48
96
  Autotest.add_hook :run_command do
49
- @label = (@@hide_label) ? ('') : (File.basename(Dir.pwd).upcase + ': ')
50
- @run_scenarios = false
97
+ @label = File.basename(Dir.pwd).upcase + ': ' if !@@hide_label
51
98
  print "\n"*2 + '-'*80 + "\n"*2
52
- print "\e[2J\e[f" # clear the terminal
99
+ print "\e[2J\e[f" if @@clear_terminal
53
100
  false
54
101
  end
55
102
 
56
103
  ##
57
- # Parse the test results and send them to Growl.
104
+ # Parse the RSpec and Test::Unit results and send them to Growl.
58
105
  Autotest.add_hook :ran_command do |autotest|
59
- gist = autotest.results.grep(/\d+\s+(example|test)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ")
60
- if gist == ''
61
- growl @label + 'Cannot run tests.', '', 'error'
62
- else
63
- if gist =~ /[1-9]\d*\s+(failure|error)/
64
- growl @label + 'Some tests have failed.', gist, 'failed'
65
- elsif gist =~ /pending/
66
- growl @label + 'Some tests are pending.', gist, 'pending'
67
- @run_scenarios = true
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
68
127
  else
69
- growl @label + 'All tests have passed.', gist, 'passed'
70
- @run_scenarios = true
128
+ growl @label + 'Could not run tests.', '', 'error', 2
71
129
  end
130
+ @ran_test = true
72
131
  end
73
132
  false
74
133
  end
75
134
 
76
- # FIXME: This is a temporary workaround until Cucumber is properly integrated!
77
- Autotest.add_hook :waiting do |autotest|
78
- if @run_scenarios && !autotest.results.grep(/^\d+ scenario/).empty?
79
- gist = autotest.results.grep(/\d+\s+(scenario|step)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ")
80
- if gist == ''
81
- growl @label + 'Cannot run scenarios.', '', 'error'
82
- else
83
- if gist =~ /failed/
84
- growl @label + 'Some scenarios have failed.', gist, 'failed'
85
- elsif gist =~ /undefined/
86
- growl @label + 'Some scenarios are undefined.', gist, 'pending'
87
- else
88
- growl @label + 'All scenarios have passed.', gist, 'passed'
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
89
159
  end
160
+ else
161
+ growl @label + 'Could not run features.', '', 'error', 2
90
162
  end
163
+ @ran_features = true
91
164
  end
92
165
  false
93
166
  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.end_with?('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
@@ -1,8 +1,10 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
+ require File.join(File.dirname(__FILE__), 'autotest', 'growl')
5
+
4
6
  module AutotestGrowl
5
7
 
6
- VERSION = '0.1.1'
8
+ VERSION = '0.1.4'
7
9
 
8
10
  end
data/script/console CHANGED
@@ -5,6 +5,6 @@ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
5
5
  libs = " -r irb/completion"
6
6
  # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
7
  # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/autotest-growl.rb'}"
9
- puts "Loading autotest-growl gem"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/testli.rb'}"
9
+ puts "Loading testli gem"
10
10
  exec "#{irb} #{libs} --simple-prompt"
@@ -1 +1,80 @@
1
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_helper.rb CHANGED
@@ -7,4 +7,10 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'autotest-growl'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svoop-autotest-growl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-03 00:00:00 -07:00
12
+ date: 2009-07-23 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,17 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 4.1.0
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: newgem
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.4.1
23
+ version: 4.1.3
34
24
  version:
35
25
  - !ruby/object:Gem::Dependency
36
26
  name: hoe
@@ -40,7 +30,7 @@ dependencies:
40
30
  requirements:
41
31
  - - ">="
42
32
  - !ruby/object:Gem::Version
43
- version: 1.8.0
33
+ version: 2.3.2
44
34
  version:
45
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.
46
36
  email:
@@ -53,7 +43,6 @@ extra_rdoc_files:
53
43
  - History.txt
54
44
  - Manifest.txt
55
45
  - PostInstall.txt
56
- - README.rdoc
57
46
  files:
58
47
  - History.txt
59
48
  - Manifest.txt
@@ -62,12 +51,16 @@ files:
62
51
  - Rakefile
63
52
  - autotest-growl.gemspec
64
53
  - growl/growlnotify
54
+ - growl/growlnotify.com
55
+ - growl/growlnotify.exe
65
56
  - img/error.png
66
57
  - img/failed.png
58
+ - img/info.png
67
59
  - img/passed.png
68
60
  - img/pending.png
69
61
  - lib/autotest-growl.rb
70
62
  - lib/autotest/growl.rb
63
+ - lib/autotest/result.rb
71
64
  - script/console
72
65
  - script/destroy
73
66
  - script/generate
@@ -92,7 +85,7 @@ post_install_message: "\n\
92
85
  | ZenTest no longer comes with bundled Growl support and therefore the |\n\
93
86
  | require in your ~/.autotest must not contain the absolute path to this |\n\
94
87
  | gem anymore. Please update your ~/.autotest to contain the require line |\n\
95
- | mentioned above. |\n\
88
+ | mentioned above. Make sure no ZenTest version <=4.0.0 is installed. |\n\
96
89
  +-------------------------------------------------------------------------+\n\
97
90
  \e[0;30m\n"
98
91
  rdoc_options: