autotest-growl 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,10 @@
1
+ == 0.1.2 2009-06-12
2
+
3
+ * 3 major improvements
4
+ * Add priorities to notifications (Michael Moen)
5
+ * Add clear_terminal configuration option (Michael Moen)
6
+ * Add show_modified_files configuration option (Graham Savage)
7
+
1
8
  == 0.1.1 2009-06-02
2
9
 
3
10
  * 1 major improvement
@@ -7,6 +7,7 @@ autotest-growl.gemspec
7
7
  growl/growlnotify
8
8
  img/error.png
9
9
  img/failed.png
10
+ img/info.png
10
11
  img/passed.png
11
12
  img/pending.png
12
13
  lib/autotest-growl.rb
@@ -19,5 +19,5 @@ http://www.bitcetera.com/products/autotest-growl
19
19
  | ZenTest no longer comes with bundled Growl support and therefore the |
20
20
  | require in your ~/.autotest must not contain the absolute path to this |
21
21
  | gem anymore. Please update your ~/.autotest to contain the require line |
22
- | mentioned above. |
22
+ | mentioned above. Make sure no ZenTest version <=4.0.0 is installed. |
23
23
  +-------------------------------------------------------------------------+
@@ -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 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
 
@@ -44,7 +55,14 @@ http://growl.info
44
55
 
45
56
  Using your own set of icons is pretty simple. Just create a directory
46
57
  ~/.autotest-growl, copy your icons there and name them passed.png,
47
- pending.png, failed.png and error.png.
58
+ pending.png, failed.png, error.png and info.png.
59
+
60
+ === Don't Clear the Terminal
61
+
62
+ Add the following to your ~/.autotest if you don't want the terminal to
63
+ be cleared before running a test:
64
+
65
+ Autotest::Growl::clear_terminal = false
48
66
 
49
67
  === Hide the Label
50
68
 
@@ -53,8 +71,30 @@ All tests have passed", add the following to your ~/.autotest:
53
71
 
54
72
  Autotest::Growl::hide_label = true
55
73
 
74
+ === Show Modified Files
75
+
76
+ Add the following to your ~/.autotest if you would like to receive a Growl
77
+ notification listing the files modified before tests are re-run.
78
+
79
+ Autotest::Growl::show_modified_files = true
80
+
56
81
  == TROUBLESHOOTING:
57
82
 
83
+ === Loading the Plugin Seems to Fail
84
+
85
+ Most likely you still have an old version of ZenTest <= 4.0.0 installed,
86
+ check it with:
87
+
88
+ gem list ZenTest
89
+
90
+ To uninstall a specific version (e.g. 4.0.0), type:
91
+
92
+ sudo gem uninstall ZenTest --version=4.0.0
93
+
94
+ Or remove all outdated versions of all installed gems:
95
+
96
+ sudo gem cleanup
97
+
58
98
  === Missing Cucumber Notifications
59
99
 
60
100
  If you are using autotest-fsevent as well, the require statements are not
@@ -98,6 +138,13 @@ pull request:
98
138
 
99
139
  http://github.com/guides/fork-a-project-and-submit-your-modifications
100
140
 
141
+ == CONTRIBUTIONS:
142
+
143
+ Thanks to the following folks who have contributed to this project:
144
+
145
+ * Michael Moen
146
+ * Graham Savage
147
+
101
148
  == LICENSE:
102
149
 
103
150
  (The MIT License)
data/Rakefile CHANGED
@@ -25,3 +25,5 @@ end
25
25
 
26
26
  require 'newgem/tasks'
27
27
  Dir['tasks/**/*.rake'].each { |t| load t }
28
+
29
+ task :default => [:spec]
Binary file
@@ -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.dirname(__FILE__) + '/autotest/growl'
5
+
4
6
  module AutotestGrowl
5
7
 
6
- VERSION = '0.1.1'
8
+ VERSION = '0.1.2'
7
9
 
8
10
  end
@@ -15,8 +15,13 @@ module Autotest::Growl
15
15
 
16
16
  GEM_PATH = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
17
17
 
18
+ @label = ''
19
+ @modified_files = []
20
+
18
21
  @@remote_notification = false
22
+ @@clear_terminal = true
19
23
  @@hide_label = false
24
+ @@show_modified_files = false
20
25
 
21
26
  ##
22
27
  # Whether to use remote or local notificaton (default).
@@ -24,12 +29,24 @@ module Autotest::Growl
24
29
  @@remote_notification = boolean
25
30
  end
26
31
 
32
+ ##
33
+ # Whether to clear the terminal before running tests (default) or not.
34
+ def self.clear_terminal=(boolean)
35
+ @@clear_terminal = boolean
36
+ end
37
+
27
38
  ##
28
39
  # Whether to display the label (default) or not.
29
40
  def self.hide_label=(boolean)
30
41
  @@hide_label = boolean
31
42
  end
32
43
 
44
+ ##
45
+ # Whether to display the modified files or not (default).
46
+ def self.show_modified_files=(boolean)
47
+ @@show_modified_files = boolean
48
+ end
49
+
33
50
  ##
34
51
  # Display a message through Growl.
35
52
  def self.growl title, message, icon, priority=0, stick=""
@@ -43,13 +60,25 @@ module Autotest::Growl
43
60
  end
44
61
  end
45
62
 
63
+ ##
64
+ # Display the modified files.
65
+ Autotest.add_hook :updated do |autotest, modified|
66
+ if @@show_modified_files
67
+ if modified != @last_modified
68
+ growl @label + 'Modifications detected.', modified.collect {|m| m[0]}.join(', '), 'info', 0
69
+ @last_modified = modified
70
+ end
71
+ end
72
+ false
73
+ end
74
+
46
75
  ##
47
76
  # Set the label and clear the terminal.
48
77
  Autotest.add_hook :run_command do
49
- @label = (@@hide_label) ? ('') : (File.basename(Dir.pwd).upcase + ': ')
78
+ @label = File.basename(Dir.pwd).upcase + ': ' if !@@hide_label
50
79
  @run_scenarios = false
51
80
  print "\n"*2 + '-'*80 + "\n"*2
52
- print "\e[2J\e[f" # clear the terminal
81
+ print "\e[2J\e[f" if @@clear_terminal
53
82
  false
54
83
  end
55
84
 
@@ -58,15 +87,15 @@ module Autotest::Growl
58
87
  Autotest.add_hook :ran_command do |autotest|
59
88
  gist = autotest.results.grep(/\d+\s+(example|test)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ")
60
89
  if gist == ''
61
- growl @label + 'Cannot run tests.', '', 'error'
90
+ growl @label + 'Cannot run tests.', '', 'error', 2
62
91
  else
63
92
  if gist =~ /[1-9]\d*\s+(failure|error)/
64
- growl @label + 'Some tests have failed.', gist, 'failed'
93
+ growl @label + 'Some tests have failed.', gist, 'failed', 2
65
94
  elsif gist =~ /pending/
66
- growl @label + 'Some tests are pending.', gist, 'pending'
95
+ growl @label + 'Some tests are pending.', gist, 'pending', -1
67
96
  @run_scenarios = true
68
97
  else
69
- growl @label + 'All tests have passed.', gist, 'passed'
98
+ growl @label + 'All tests have passed.', gist, 'passed', -2
70
99
  @run_scenarios = true
71
100
  end
72
101
  end
@@ -78,14 +107,14 @@ module Autotest::Growl
78
107
  if @run_scenarios && !autotest.results.grep(/^\d+ scenario/).empty?
79
108
  gist = autotest.results.grep(/\d+\s+(scenario|step)s?/).map {|s| s.gsub(/(\e.*?m|\n)/, '') }.join(" / ")
80
109
  if gist == ''
81
- growl @label + 'Cannot run scenarios.', '', 'error'
110
+ growl @label + 'Cannot run scenarios.', '', 'error', 2
82
111
  else
83
112
  if gist =~ /failed/
84
- growl @label + 'Some scenarios have failed.', gist, 'failed'
113
+ growl @label + 'Some scenarios have failed.', gist, 'failed', 2
85
114
  elsif gist =~ /undefined/
86
- growl @label + 'Some scenarios are undefined.', gist, 'pending'
115
+ growl @label + 'Some scenarios are undefined.', gist, 'pending', -1
87
116
  else
88
- growl @label + 'All scenarios have passed.', gist, 'passed'
117
+ growl @label + 'All scenarios have passed.', gist, 'passed', -2
89
118
  end
90
119
  end
91
120
  end
@@ -1 +1,50 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "handling results" do
4
+ before do
5
+ @autotest = Autotest.new
6
+ end
7
+
8
+ describe "for RSpec" do
9
+ it "should show a passing Growl notification" do
10
+ Autotest::Growl.should_receive(:growl).and_return('passed')
11
+ @autotest.results = ["10 examples, 0 failures"]
12
+ @autotest.hook(:ran_command)
13
+ end
14
+
15
+ it "should show a failing Growl notification" do
16
+ Autotest::Growl.should_receive(:growl).and_return('passed')
17
+ @autotest.results = ["10 examples, 1 failures"]
18
+ @autotest.hook(:ran_command)
19
+ end
20
+
21
+ it "should show a pending Growl notification" do
22
+ Autotest::Growl.should_receive(:growl).and_return('passed')
23
+ @autotest.results = ["10 examples, 0 failures, 1 pending"]
24
+ @autotest.hook(:ran_command)
25
+ end
26
+ end
27
+
28
+ describe "for Test::Unit" do
29
+ it "should show a passing Growl notification" do
30
+ Autotest::Growl.should_receive(:growl).and_return('passed')
31
+ @autotest.results = ["1 tests, 1 assertions, 0 failures, 0 errors"]
32
+ @autotest.hook(:ran_command)
33
+ end
34
+
35
+ it "should show a failing Growl notification" do
36
+ Autotest::Growl.should_receive(:growl).twice.and_return('passed')
37
+ @autotest.results = ["1 tests, 1 assertions, 1 failures, 0 errors"]
38
+ @autotest.hook(:ran_command)
39
+ @autotest.results = ["1 tests, 1 assertions, 0 failures, 1 errors"]
40
+ @autotest.hook(:ran_command)
41
+ end
42
+ end
43
+
44
+ # FIXME: This is a temporary workaround until Cucumber is properly integrated!
45
+ describe "for Cucumber" do
46
+ it "should show a passing Growl notification"
47
+ it "should show a failing Growl notification"
48
+ it "should show a pending Growl notification"
49
+ end
50
+ end
@@ -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: autotest-growl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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 +02:00
12
+ date: 2009-06-12 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -64,6 +64,7 @@ files:
64
64
  - growl/growlnotify
65
65
  - img/error.png
66
66
  - img/failed.png
67
+ - img/info.png
67
68
  - img/passed.png
68
69
  - img/pending.png
69
70
  - lib/autotest-growl.rb
@@ -94,7 +95,7 @@ post_install_message: "\n\
94
95
  | ZenTest no longer comes with bundled Growl support and therefore the |\n\
95
96
  | require in your ~/.autotest must not contain the absolute path to this |\n\
96
97
  | gem anymore. Please update your ~/.autotest to contain the require line |\n\
97
- | mentioned above. |\n\
98
+ | mentioned above. Make sure no ZenTest version <=4.0.0 is installed. |\n\
98
99
  +-------------------------------------------------------------------------+\n\
99
100
  \e[0;30m\n"
100
101
  rdoc_options: