ZenTest 3.5.2 → 3.6.0

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,270 +1,286 @@
1
- *** 3.5.2
2
-
3
- + 4 bug fixes:
4
- + Patch up Rails fixture defaults for Test::Rails::TestCase.
5
- + Session now properly hooked up to controllers.
6
- + ruby 1.8.6 has a bug on 'raise Interrupt' with no args. Fixed on both sides.
7
- + Fixed redgreen to work with new getc/putc-based output. (from Finn Smith)
8
-
9
- *** 3.5.1 / 2007-04-17
10
-
11
- + 4 bug fixes:
12
- + Fixed gem name to be camel-case again. Fixed on rubyforge too.
13
- + Fixed rdoc for hooks.
14
- + Fixed redgreen, results changed to an array.
15
- + Patch up Rails fixture defaults, since they're not inheriting properly.
16
-
17
- *** 3.5.0 / 2007-04-12
18
-
19
- + 4 major enhancements:
20
- + Now requires RubyGems 0.9.1 or newer.
21
- + Autotest and unit_diff are both unbuffered. Results are more live.
22
- + Refactored and redesigned how files map to test from Sean Carley. See fixtures plugin as an example.
23
- + Generalize how autotest handler is instantiated and invoked, allowing for many more autotest types, including combos.
24
- + 23 minor enhancements:
25
- + Added all_good hook if initial run was all_good as well.
26
- + Added assert_in_epsilon to ZentestAssertions.
27
- + Added autotest plugin to auto-update source ala tinderbox/cruisecontrol.
28
- + Added autotest plugin to update ichat/adium IM status with code stats.
29
- + Added autotest plugin to update the GNU screen statusbar from Yuichi Tateno.
30
- + Added autotest syntax error handling from Ryan Platte.
31
- + Added autotest/emacs emacs integration plugin!!! YAY!
32
- + Added autotest/migrate.rb.
33
- + Added camping support from Geoffrey Grossenbach.
34
- + Added changed file reporting to autotest via -v flag.
35
- + Added informative summary and filtering via ENV['VERSIONS'] to multiruby.
36
- + Added libnotify support from Kazuo Saito.
37
- + Added lots of rdoc patches from Hugh Sasse.
38
- + Added rjs files to view_test_case.
39
- + Added rspec_autotest "stolen" from caldersphere.net
40
- + Added run_command hook to trigger the start of a test run.
41
- + Added tmp to rails' exceptions list.
42
- + Added unit_diff command variable to autotest for customizing flags and such.
43
- + Added zentest_mapping.rb and test.
44
- + Allow session to work in Test::Rails view tests.
45
- + Improved autotest/growl.rb output from imajes.
46
- + Improved autotest/timestamp output from Josh Susser.
47
- + Test::Rails works with Rails 1.2.
48
- + 2 bug fixes:
49
- + Accelerated Test::Rails unit tests via sensible defaults.
50
- + Better assertion messages for ZentestAssertions.
51
-
52
- *** 3.4.3 / 2006-12-19
53
-
54
- + 2 minor enhancements:
55
- + Add assert_title and assert_h (for header).
56
- + 2 bug fixes:
57
- + Rereleased against latest version of hoe to fix load path problems.
58
- + Fix case ViewTestCase for case-sensitive file systems.
59
-
60
- *** 3.4.2 / 2006-11-09
61
-
62
- + 2 minor enhancements:
63
- + Add TextHelper for pluralize.
64
- + Add deny_nil to Test::Rails.
65
- + 7 bug fixes:
66
- + Fixed test_help's Flash. It's is a module. Oops...
67
- + Don't run util_audit_assert_assigned if tests didn't pass, results will be bogus.
68
- + Fixed AssertionsTest names to match what autotest expects.
69
- + Fixed bug where deny_includes failed for Symbol keys.
70
- + Switched autotest to use require instead of load... Why??? I don't know!!
71
- + Fixed a minor but annoying whitespace difference in unit_diff.
72
- + Switched argument order of assert_includes and deny_includes to match Test::Unit convention.
73
-
74
- *** 3.4.1 / 2006-10-13
75
-
76
- + 3 minor enhancements:
77
- + FUNDAMENTALLY changed the way failures map back to tests. This REQUIRES users of autotest to ensure that their tests and impls map 1:1 at every scoping level. I'll blog more details.
78
- + Hoe'd rakefile
79
- + Added support for render :collection to RenderTree.
80
- + 7 bug fixes:
81
- + Fixed autotest tests for custom ruby names.
82
- + Fixed some documentation errors in ControllerTestCase.
83
- + Fixed setup in FunctionalTestCase.
84
- + Allowed @assigns_ignored to contain either Symbols or Strings, bug 5233.
85
- + Using Object.path2class to look up classes in helper test cases, bug 5493.
86
- + Added assert_text_area, bug 5452.
87
- + Renamed assert_select to assert_select_tag. Stupid rails. We were here first.
88
-
89
- *** 3.4.0 / 2006-09-12
90
-
91
- + 13 minor enhancements:
92
- * Broke out example_dot_autotest into multiple files in lib.
93
- * Enhanced hook system so it can return true if event handled.
94
- * Sleep is now 1 second by default because life is too short.
95
- * Hooked interrupt with new hook system. First handler wins.
96
- * Hooked test results before output
97
- * Accurate test counts for Test::Rails.
98
- * Added snarl autotest plugin, thanks to Patrick Hurley.
99
- * Added timestamp autotest plugin, thanks to Joe Goldberg.
100
- * Added redgreen, thanks to Pat Eyler, Sean Carley, and Rob Sanheim.
101
- * Added kdenotify autotest plugin, thanks to Geir Freysson.
102
- * Added markaby support for Test::Rails.
103
- * Added hack to display a tree of render calls.
104
- * Added hook to perform extra setup for
105
- + 5 bug fixes:
106
- - Extended zentest to deal with rails a bit better... ugh.
107
- - Fixed @libs for windoze.
108
- - Fixed inner class/test identification in autotest.
109
- - Namespaced all plugins... eric is anal.
110
- - No longer freak out if rubygems tarball not in multiruby/versions.
111
-
112
- *** 3.3.0 / 2006-07-28
113
-
114
- + 1 major enhancement:
115
- + autotest has been rewritten to be much cleaner, now has a plugin system.
116
- + 5 minor enhancements:
117
- + test/rails adds helper tests, "stolen" from Geoff's work, (which was "stolen" from ryan's work. :P)
118
- + autotest turnaround is now faster.
119
- + Added more prune dirs to autotest.
120
- + test/rails rewinds IOs containing captured output. Added assert_empty.
121
- + Document that autotest doesn't run the db:test:prepare rake task when in Rails mode.
122
- + Added ruby_fork, but haven't fully plugged into autotest yet.
123
- + 7 bug fixes:
124
- + Add SIGINT handler to unit_diff to give a more graceful exit.
125
- + Don't strip <> from tempfiles, parse_diff does it for us.
126
- + Fixed autotest problems on windoze. Ugh.
127
- + Fixed broken pipe bug and newline bug in unit_diff.
128
- + Make request_method in ControllerTestCase a String.
129
- + multitest installs rubygems if tarball found in versions dir.
130
- + multitest only configures when makefile is missing. Rebuilds much faster now.
131
- + ruby_fork exits without backtrace and allows redirection of output.
132
-
133
- *** 3.2.0 / 2006-04-10
134
-
135
- + 1 major enhancement:
136
- + Added Test::Rails.
137
- + 1 minor enhancement:
138
- + Extended autotest for Test::Rails.
139
- + 4 bug fixes:
140
- + Autotest now detects changes in rhtml.
141
- + Improved autotest's file mapping and choice of ruby.
142
- + We've got RDoc, yes we do!
143
- + Removed redundancies in rakefile. Using gem spec for most stuff now.
144
-
145
- *** 3.1.0 / 2006-03-29
146
-
147
- + 2 major enhancements:
148
- + Added multiruby! YAY!
149
- + Massive improvements to autotest: speed, reliability, reporting, etc.
150
- + 10 minor enhancements:
151
- + multiruby builds in a centralized location. YAY!
152
- + multiruby now allows reinstalls quickly and easily (can even skip config).
153
- + multiruby exits with total sum of exit codes.
154
- + autotest file search is muuuuch faster.
155
- + autotest automatically detects rails mode.
156
- + autotest deals with rails dependencies much better.
157
- + autotest reruns a full suite after you go green to ensure full coverage.
158
- + autotest always runs with unit_diff -u.
159
- + autotest can now run cvs/svn/p4 up periodically to be a mini-tinderbox.
160
- + autotest now has real help.
161
- + 4 bug fixes:
162
- + ZenTest is now zentest. Yay for consistency! (do a rake uninstall to clean)
163
- + ZenTest excludes pretty_print methods.
164
- + Fixed unary operator issues (they were backwards... oops!) for ZenTest.
165
- + unit_diff now runs diff.exe on Windoze. dunno if that will work.
166
-
167
- *** 3.0.0 / 2006-03-06
168
-
169
- + 2 major enhancements:
170
- + Added autotest and rails_autotest. YAY for continous testing!
171
- + Repackaged and gemified. YAY for gemification!
172
- + 3 minor enhancements:
173
- + Added non-mappable tests starting with test_integration_.
174
- + Lots of code and test refactoring and cleanup.
175
- + Massive improvement on unit tests.
176
- + 3 bug fixes:
177
- + Cleaned up class method inheritence. Esp relevant for rails testing.
178
- + Finally fixed the unit_diff parse bug!
179
- + Fixed improper counting of errors if a class was missing, should be 1 + missing methods.
180
-
181
- *** 2.4.0 / 2005-03-21
182
-
183
- + 3 minor enhancements:
184
- + Able to audit standard class library (so now we can audit rubicon!).
185
- + Able to map against class methods (self.blah <=> test_class_blah).
186
- + Added -I=rubypath support
187
- + 4 bug fixes:
188
- + bug:1151 Fixed stupid problem w/ unit_diff.
189
- + bug:1454 code generation correctly matches class/module for nested classes.
190
- + bug:1455 Updated method mapping to work on all operators listed in my quickref.
191
- + Realized I'm a moron and did NOT release in March like I thought...
192
-
193
- *** 2.3.0 / 2004-11-18
194
-
195
- + 6 minor enhancements:
196
- + Massively expanded the method name mappings.
197
- + Added -r flag to reverse map names, for Rails style testing.
198
- + Added -e to auto eval tests generated.
199
- + Added -b & -c flags in unit_diff (passed to diff)
200
- + Added install and uninstall rules to Makefile.
201
- + Added some more doco to README.txt
202
- + 7 bug fixes:
203
- + Cleaned up and refactored tests.
204
- + Changed the way files are generated, to accomodate new flags.
205
- + Added some more tests.
206
- + Added $ZENTEST=true
207
- + Fixed the one-liner diff bug.
208
- + Cleaned up multi-line string diffs by unescaping \n
209
- + Cleaned result for flunks.
210
-
211
- *** 2.2.0 / 2004-10-18
212
-
213
- + 4 minor enhancements:
214
- + Added LinuxJournalArticle.txt! WOOT!
215
- + Added unit_diff.rb - a very cool filter for test output!
216
- + Extended ZenTest to work with standard input
217
- + Added "ZenTest FULL" to force ZenTest to analyze inherited methods, for subclasses of the standard library.
218
- + 3 bug fixes:
219
- + Extended makefile to be more dynamic and stop diffing versions. ugh.
220
- + Expanded the method rename map to handle <<, *, +, and ==.
221
- + Added more test cases.
222
-
223
- *** 2.1.2 / 2004-03-08
224
-
225
- + 4 bug fixes:
226
- + Fixed yet another 1.8ism, results will be the same in 1.8 and 1.6.
227
- + Fixed code responsible for method name conversion.
228
- + I am a moron... didn't run tests after updating version.
229
- + Need to convert my diff-based tests to unit tests.
230
-
231
- *** 2.1.1 / 2004-03-06
232
-
233
- + 3 bug fixes:
234
- + Fixed a 1.8ism.
235
- + Removed zentestrunner. Older ruby users will just have to suffer.
236
- + Updated history to ZenWeb format.
237
-
238
- *** 2.1.0 / 2003-01-07
239
-
240
- + 3 major enhancements:
241
- + Output is runnable as-is thanks to zentestrunner.rb.
242
- + Wrapped up all running functionality into ZenTest.fix
243
- + Added simple statistic output... Thanks Dave & Andy!!!
244
- + 2 minor enhancements:
245
- + Added zentestrunner.rb until Nathaniel accepts my changes!
246
- + Added a clean rule to Makefile
247
- + 3 bug fixes:
248
- + Removed at_exit override and avoided test/unit altogether.
249
- + Extended README.txt to include some of the rules.
250
- + Fixed several tests and added assertions for new stats
251
-
252
- *** 2.0.0 / 2002-10-29
253
-
254
- + 2 major enhancements:
255
- + Rewrite of ZenTest.rb into actual OO design.
256
- + Added unit tests, finally...
257
-
258
- *** 1.0.1 / 2002-09-28
259
-
260
- + 1 minor enhancement:
261
- + Only loads when a class is detected, allows some scripts to be skipped.
262
- + 3 bug fixes:
263
- + Cleaned up output. Verbose when $DEBUG is true.
264
- + Added an error count that is output at end.
265
- + Better filtering or conversion on some method names.
266
-
267
- *** 1.0.0 / 2002-09-24
268
-
269
- + 1 major enhancement:
270
- + Birthday!
1
+ === 3.6.0 / 2007-05-25
2
+
3
+ * 4 major enhancements:
4
+ * New auto-discovery mechanism to make rspec and friends work independently!
5
+ * Moved and restructured camping and rails as plugins.
6
+ * Removed rspec - now packaged with rspec and/or as plugin.
7
+ * Changed the way FTM tests are named. Allows multiple matricies.
8
+ * 3 minor enhancements:
9
+ * Added :OK special result value to FTM.
10
+ * Hugh Sasse is awesome. Rdoc happiness.
11
+ * Parameterized emacs client command.
12
+ * 3 bug fixes:
13
+ * Dup load path because I'm dum.
14
+ * Fixed a lame syntax error in emacs.rb.
15
+ * autotest now builds command separator with '&' on windoze. ARGH! Why is this the first I've heard of this?!?
16
+
17
+ === 3.5.2 / 2007-04-30
18
+
19
+ * 4 bug fixes:
20
+ * Patch up Rails fixture defaults for Test::Rails::TestCase.
21
+ * Session now properly hooked up to controllers.
22
+ * ruby 1.8.6 has a bug on 'raise Interrupt' with no args. Fixed on both sides.
23
+ * Fixed redgreen to work with new getc/putc-based output. (from Finn Smith)
24
+
25
+ === 3.5.1 / 2007-04-17
26
+
27
+ * 4 bug fixes:
28
+ * Fixed gem name to be camel-case again. Fixed on rubyforge too.
29
+ * Fixed rdoc for hooks.
30
+ * Fixed redgreen, results changed to an array.
31
+ * Patch up Rails fixture defaults, since they're not inheriting properly.
32
+
33
+ === 3.5.0 / 2007-04-12
34
+
35
+ * 4 major enhancements:
36
+ * Now requires RubyGems 0.9.1 or newer.
37
+ * Autotest and unit_diff are both unbuffered. Results are more live.
38
+ * Refactored and redesigned how files map to test from Sean Carley. See fixtures plugin as an example.
39
+ * Generalize how autotest handler is instantiated and invoked, allowing for many more autotest types, including combos.
40
+ * 23 minor enhancements:
41
+ * Added all_good hook if initial run was all_good as well.
42
+ * Added assert_in_epsilon to ZentestAssertions.
43
+ * Added autotest plugin to auto-update source ala tinderbox/cruisecontrol.
44
+ * Added autotest plugin to update ichat/adium IM status with code stats.
45
+ * Added autotest plugin to update the GNU screen statusbar from Yuichi Tateno.
46
+ * Added autotest syntax error handling from Ryan Platte.
47
+ * Added autotest/emacs emacs integration plugin!!! YAY!
48
+ * Added autotest/migrate.rb.
49
+ * Added camping support from Geoffrey Grossenbach.
50
+ * Added changed file reporting to autotest via -v flag.
51
+ * Added informative summary and filtering via ENV['VERSIONS'] to multiruby.
52
+ * Added libnotify support from Kazuo Saito.
53
+ * Added lots of rdoc patches from Hugh Sasse.
54
+ * Added rjs files to view_test_case.
55
+ * Added rspec_autotest "stolen" from caldersphere.net
56
+ * Added run_command hook to trigger the start of a test run.
57
+ * Added tmp to rails' exceptions list.
58
+ * Added unit_diff command variable to autotest for customizing flags and such.
59
+ * Added zentest_mapping.rb and test.
60
+ * Allow session to work in Test::Rails view tests.
61
+ * Improved autotest/growl.rb output from imajes.
62
+ * Improved autotest/timestamp output from Josh Susser.
63
+ * Test::Rails works with Rails 1.2.
64
+ * 2 bug fixes:
65
+ * Accelerated Test::Rails unit tests via sensible defaults.
66
+ * Better assertion messages for ZentestAssertions.
67
+
68
+ === 3.4.3 / 2006-12-19
69
+
70
+ * 2 minor enhancements:
71
+ * Add assert_title and assert_h (for header).
72
+ * 2 bug fixes:
73
+ * Rereleased against latest version of hoe to fix load path problems.
74
+ * Fix case ViewTestCase for case-sensitive file systems.
75
+
76
+ === 3.4.2 / 2006-11-09
77
+
78
+ * 2 minor enhancements:
79
+ * Add TextHelper for pluralize.
80
+ * Add deny_nil to Test::Rails.
81
+ * 7 bug fixes:
82
+ * Fixed test_help's Flash. It's is a module. Oops...
83
+ * Don't run util_audit_assert_assigned if tests didn't pass, results will be bogus.
84
+ * Fixed AssertionsTest names to match what autotest expects.
85
+ * Fixed bug where deny_includes failed for Symbol keys.
86
+ * Switched autotest to use require instead of load... Why??? I don't know!!
87
+ * Fixed a minor but annoying whitespace difference in unit_diff.
88
+ * Switched argument order of assert_includes and deny_includes to match Test::Unit convention.
89
+
90
+ === 3.4.1 / 2006-10-13
91
+
92
+ * 3 minor enhancements:
93
+ * FUNDAMENTALLY changed the way failures map back to tests. This REQUIRES users of autotest to ensure that their tests and impls map 1:1 at every scoping level. I'll blog more details.
94
+ * Hoe'd rakefile
95
+ * Added support for render :collection to RenderTree.
96
+ * 7 bug fixes:
97
+ * Fixed autotest tests for custom ruby names.
98
+ * Fixed some documentation errors in ControllerTestCase.
99
+ * Fixed setup in FunctionalTestCase.
100
+ * Allowed @assigns_ignored to contain either Symbols or Strings, bug 5233.
101
+ * Using Object.path2class to look up classes in helper test cases, bug 5493.
102
+ * Added assert_text_area, bug 5452.
103
+ * Renamed assert_select to assert_select_tag. Stupid rails. We were here first.
104
+
105
+ === 3.4.0 / 2006-09-12
106
+
107
+ * 13 minor enhancements:
108
+ * Broke out example_dot_autotest into multiple files in lib.
109
+ * Enhanced hook system so it can return true if event handled.
110
+ * Sleep is now 1 second by default because life is too short.
111
+ * Hooked interrupt with new hook system. First handler wins.
112
+ * Hooked test results before output
113
+ * Accurate test counts for Test::Rails.
114
+ * Added snarl autotest plugin, thanks to Patrick Hurley.
115
+ * Added timestamp autotest plugin, thanks to Joe Goldberg.
116
+ * Added redgreen, thanks to Pat Eyler, Sean Carley, and Rob Sanheim.
117
+ * Added kdenotify autotest plugin, thanks to Geir Freysson.
118
+ * Added markaby support for Test::Rails.
119
+ * Added hack to display a tree of render calls.
120
+ * Added hook to perform extra setup for
121
+ * 5 bug fixes:
122
+ - Extended zentest to deal with rails a bit better... ugh.
123
+ - Fixed @libs for windoze.
124
+ - Fixed inner class/test identification in autotest.
125
+ - Namespaced all plugins... eric is anal.
126
+ - No longer freak out if rubygems tarball not in multiruby/versions.
127
+
128
+ === 3.3.0 / 2006-07-28
129
+
130
+ * 1 major enhancement:
131
+ * autotest has been rewritten to be much cleaner, now has a plugin system.
132
+ * 5 minor enhancements:
133
+ * test/rails adds helper tests, "stolen" from Geoff's work, (which was "stolen" from ryan's work. :P)
134
+ * autotest turnaround is now faster.
135
+ * Added more prune dirs to autotest.
136
+ * test/rails rewinds IOs containing captured output. Added assert_empty.
137
+ * Document that autotest doesn't run the db:test:prepare rake task when in Rails mode.
138
+ * Added ruby_fork, but haven't fully plugged into autotest yet.
139
+ * 7 bug fixes:
140
+ * Add SIGINT handler to unit_diff to give a more graceful exit.
141
+ * Don't strip <> from tempfiles, parse_diff does it for us.
142
+ * Fixed autotest problems on windoze. Ugh.
143
+ * Fixed broken pipe bug and newline bug in unit_diff.
144
+ * Make request_method in ControllerTestCase a String.
145
+ * multitest installs rubygems if tarball found in versions dir.
146
+ * multitest only configures when makefile is missing. Rebuilds much faster now.
147
+ * ruby_fork exits without backtrace and allows redirection of output.
148
+
149
+ === 3.2.0 / 2006-04-10
150
+
151
+ * 1 major enhancement:
152
+ * Added Test::Rails.
153
+ * 1 minor enhancement:
154
+ * Extended autotest for Test::Rails.
155
+ * 4 bug fixes:
156
+ * Autotest now detects changes in rhtml.
157
+ * Improved autotest's file mapping and choice of ruby.
158
+ * We've got RDoc, yes we do!
159
+ * Removed redundancies in rakefile. Using gem spec for most stuff now.
160
+
161
+ === 3.1.0 / 2006-03-29
162
+
163
+ * 2 major enhancements:
164
+ * Added multiruby! YAY!
165
+ * Massive improvements to autotest: speed, reliability, reporting, etc.
166
+ * 10 minor enhancements:
167
+ * multiruby builds in a centralized location. YAY!
168
+ * multiruby now allows reinstalls quickly and easily (can even skip config).
169
+ * multiruby exits with total sum of exit codes.
170
+ * autotest file search is muuuuch faster.
171
+ * autotest automatically detects rails mode.
172
+ * autotest deals with rails dependencies much better.
173
+ * autotest reruns a full suite after you go green to ensure full coverage.
174
+ * autotest always runs with unit_diff -u.
175
+ * autotest can now run cvs/svn/p4 up periodically to be a mini-tinderbox.
176
+ * autotest now has real help.
177
+ * 4 bug fixes:
178
+ * ZenTest is now zentest. Yay for consistency! (do a rake uninstall to clean)
179
+ * ZenTest excludes pretty_print methods.
180
+ * Fixed unary operator issues (they were backwards... oops!) for ZenTest.
181
+ * unit_diff now runs diff.exe on Windoze. dunno if that will work.
182
+
183
+ === 3.0.0 / 2006-03-06
184
+
185
+ * 2 major enhancements:
186
+ * Added autotest and rails_autotest. YAY for continous testing!
187
+ * Repackaged and gemified. YAY for gemification!
188
+ * 3 minor enhancements:
189
+ * Added non-mappable tests starting with test_integration_.
190
+ * Lots of code and test refactoring and cleanup.
191
+ * Massive improvement on unit tests.
192
+ * 3 bug fixes:
193
+ * Cleaned up class method inheritence. Esp relevant for rails testing.
194
+ * Finally fixed the unit_diff parse bug!
195
+ * Fixed improper counting of errors if a class was missing, should be 1 + missing methods.
196
+
197
+ === 2.4.0 / 2005-03-21
198
+
199
+ * 3 minor enhancements:
200
+ * Able to audit standard class library (so now we can audit rubicon!).
201
+ * Able to map against class methods (self.blah <=> test_class_blah).
202
+ * Added -I=rubypath support
203
+ * 4 bug fixes:
204
+ * bug:1151 Fixed stupid problem w/ unit_diff.
205
+ * bug:1454 code generation correctly matches class/module for nested classes.
206
+ * bug:1455 Updated method mapping to work on all operators listed in my quickref.
207
+ * Realized I'm a moron and did NOT release in March like I thought...
208
+
209
+ === 2.3.0 / 2004-11-18
210
+
211
+ * 6 minor enhancements:
212
+ * Massively expanded the method name mappings.
213
+ * Added -r flag to reverse map names, for Rails style testing.
214
+ * Added -e to auto eval tests generated.
215
+ * Added -b & -c flags in unit_diff (passed to diff)
216
+ * Added install and uninstall rules to Makefile.
217
+ * Added some more doco to README.txt
218
+ * 7 bug fixes:
219
+ * Cleaned up and refactored tests.
220
+ * Changed the way files are generated, to accomodate new flags.
221
+ * Added some more tests.
222
+ * Added $ZENTEST=true
223
+ * Fixed the one-liner diff bug.
224
+ * Cleaned up multi-line string diffs by unescaping \n
225
+ * Cleaned result for flunks.
226
+
227
+ === 2.2.0 / 2004-10-18
228
+
229
+ * 4 minor enhancements:
230
+ * Added LinuxJournalArticle.txt! WOOT!
231
+ * Added unit_diff.rb - a very cool filter for test output!
232
+ * Extended ZenTest to work with standard input
233
+ * Added "ZenTest FULL" to force ZenTest to analyze inherited methods, for subclasses of the standard library.
234
+ * 3 bug fixes:
235
+ * Extended makefile to be more dynamic and stop diffing versions. ugh.
236
+ * Expanded the method rename map to handle <<, *, +, and ==.
237
+ * Added more test cases.
238
+
239
+ === 2.1.2 / 2004-03-08
240
+
241
+ * 4 bug fixes:
242
+ * Fixed yet another 1.8ism, results will be the same in 1.8 and 1.6.
243
+ * Fixed code responsible for method name conversion.
244
+ * I am a moron... didn't run tests after updating version.
245
+ * Need to convert my diff-based tests to unit tests.
246
+
247
+ === 2.1.1 / 2004-03-06
248
+
249
+ * 3 bug fixes:
250
+ * Fixed a 1.8ism.
251
+ * Removed zentestrunner. Older ruby users will just have to suffer.
252
+ * Updated history to ZenWeb format.
253
+
254
+ === 2.1.0 / 2003-01-07
255
+
256
+ * 3 major enhancements:
257
+ * Output is runnable as-is thanks to zentestrunner.rb.
258
+ * Wrapped up all running functionality into ZenTest.fix
259
+ * Added simple statistic output... Thanks Dave & Andy!!!
260
+ * 2 minor enhancements:
261
+ * Added zentestrunner.rb until Nathaniel accepts my changes!
262
+ * Added a clean rule to Makefile
263
+ * 3 bug fixes:
264
+ * Removed at_exit override and avoided test/unit altogether.
265
+ * Extended README.txt to include some of the rules.
266
+ * Fixed several tests and added assertions for new stats
267
+
268
+ === 2.0.0 / 2002-10-29
269
+
270
+ * 2 major enhancements:
271
+ * Rewrite of ZenTest.rb into actual OO design.
272
+ * Added unit tests, finally...
273
+
274
+ === 1.0.1 / 2002-09-28
275
+
276
+ * 1 minor enhancement:
277
+ * Only loads when a class is detected, allows some scripts to be skipped.
278
+ * 3 bug fixes:
279
+ * Cleaned up output. Verbose when $DEBUG is true.
280
+ * Added an error count that is output at end.
281
+ * Better filtering or conversion on some method names.
282
+
283
+ === 1.0.0 / 2002-09-24
284
+
285
+ * 1 major enhancement:
286
+ * Birthday!
data/Manifest.txt CHANGED
@@ -16,6 +16,8 @@ example2.rb
16
16
  example_dot_autotest.rb
17
17
  lib/autotest.rb
18
18
  lib/autotest/autoupdate.rb
19
+ lib/autotest/camping.rb
20
+ lib/autotest/discover.rb
19
21
  lib/autotest/emacs.rb
20
22
  lib/autotest/fixtures.rb
21
23
  lib/autotest/growl.rb
@@ -26,15 +28,13 @@ lib/autotest/menu.rb
26
28
  lib/autotest/migrate.rb
27
29
  lib/autotest/notify.rb
28
30
  lib/autotest/pretty.rb
31
+ lib/autotest/rails.rb
29
32
  lib/autotest/redgreen.rb
30
33
  lib/autotest/screen.rb
31
34
  lib/autotest/shame.rb
32
35
  lib/autotest/snarl.rb
33
36
  lib/autotest/timestamp.rb
34
- lib/camping_autotest.rb
35
37
  lib/functional_test_matrix.rb
36
- lib/rails_autotest.rb
37
- lib/rspec_rails_autotest.rb
38
38
  lib/ruby_fork.rb
39
39
  lib/test/rails.rb
40
40
  lib/test/rails/controller_test_case.rb
data/README.txt CHANGED
@@ -1,7 +1,8 @@
1
1
  = ZenTest
2
2
 
3
3
  * http://www.zenspider.com/ZSS/Products/ZenTest/
4
- * support@zenspider.com
4
+ * http://rubyforge.org/projects/zentest/
5
+ * mailto:ryand-ruby@zenspider.com
5
6
 
6
7
  == DESCRIPTION
7
8
 
data/Rakefile CHANGED
@@ -10,15 +10,16 @@ Hoe.new("ZenTest", ZenTest::VERSION) do |p|
10
10
  p.author = ['Ryan Davis', 'Eric Hodel']
11
11
 
12
12
  changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
13
- summary, *description = p.paragraphs_of("README.txt", 3, 3..8)
13
+ urls, summary, *description = p.paragraphs_of("README.txt", 1, 3, 3..8)
14
14
 
15
+ p.url = urls.gsub(/^\* /, '').split(/\n/)
15
16
  p.changes = changes
16
17
  p.summary = summary
17
18
  p.description = description.join("\n\n")
18
19
  end
19
20
 
20
21
  task :autotest do
21
- ruby "-Ilib ./bin/autotest"
22
+ ruby "-Ilib -w ./bin/autotest"
22
23
  end
23
24
 
24
25
  task :update do
@@ -34,6 +35,7 @@ task :update do
34
35
  f.puts
35
36
  f.puts "# Autotest::AutoUpdate.sleep_time = 60"
36
37
  f.puts "# Autotest::AutoUpdate.update_cmd = 'svn up'"
38
+ f.puts "# Autotest::Emacs.client_cmd = 'emacsclient -e'"
37
39
  f.puts "# Autotest::Heckle.flags << '-t test/**/*.rb'"
38
40
  f.puts "# Autotest::Heckle.klasses << 'MyClass'"
39
41
  f.puts "# Autotest::Shame.chat_app = :adium"
data/bin/autotest CHANGED
@@ -20,17 +20,29 @@ if $h or $help then
20
20
  exit 1
21
21
  end
22
22
 
23
- $rspec ||= false
24
- $rails ||= false
25
- $camping ||= false
26
-
27
- style = []
28
- style << "rspec" if $rspec or File.directory?('spec')
29
- style << "rails" if $rails or File.exist? 'config/environment.rb'
30
- style << "camping" if $camping or File.exist? 'test/camping_test_case.rb'
31
- style << "autotest"
23
+ class Dir
24
+ class << self
25
+ alias :old_index :[]
26
+ def [](*args)
27
+ $-w, old_warn = false, $-w
28
+ old_index(*args)
29
+ ensure
30
+ $-w = old_warn
31
+ end
32
+ end
33
+ end
32
34
 
33
- mod = style.join("_")
34
- puts "loading #{mod}"
35
- require mod
36
- Object.const_get(style.map {|s| s.capitalize}.join).run
35
+ require 'autotest'
36
+ style = Autotest.autodiscover
37
+ target = Autotest
38
+ unless style.empty? then
39
+ mod = "autotest/#{style.join("_")}"
40
+ puts "loading #{mod}"
41
+ begin
42
+ require mod
43
+ rescue LoadError
44
+ abort "Autotest style #{mod} doesn't seem to exist. Aborting."
45
+ end
46
+ target = Autotest.const_get(style.map {|s| s.capitalize}.join)
47
+ end
48
+ target.run
@@ -19,6 +19,7 @@
19
19
 
20
20
  # Autotest::AutoUpdate.sleep_time = 60
21
21
  # Autotest::AutoUpdate.update_cmd = 'svn up'
22
+ # Autotest::Emacs.client_cmd = 'emacsclient -e'
22
23
  # Autotest::Heckle.flags << '-t test/**/*.rb'
23
24
  # Autotest::Heckle.klasses << 'MyClass'
24
25
  # Autotest::Shame.chat_app = :adium
data/lib/autotest.rb CHANGED
@@ -58,6 +58,66 @@ $TESTING = false unless defined? $TESTING
58
58
  class Autotest
59
59
 
60
60
  HOOKS = Hash.new { |h,k| h[k] = [] }
61
+ unless defined? WINDOZE then
62
+ WINDOZE = /win32/ =~ RUBY_PLATFORM
63
+ SEP = WINDOZE ? '&' : ';'
64
+ end
65
+
66
+ @@discoveries = []
67
+
68
+ ##
69
+ # Add a proc to the collection of discovery procs. See
70
+ # +autodiscover+.
71
+
72
+ def self.add_discovery &proc
73
+ @@discoveries << proc
74
+ end
75
+
76
+ ##
77
+ # Automatically find all potential autotest runner styles by
78
+ # searching your loadpath, vendor/plugins, and rubygems for
79
+ # "autotest/discover.rb". If found, that file is loaded and it
80
+ # should register discovery procs with autotest using
81
+ # +add_discovery+. That proc should return one or more strings
82
+ # describing the user's current environment. Those styles are then
83
+ # combined to dynamically invoke an autotest plugin to suite your
84
+ # environment. That plugin should define a subclass of Autotest with
85
+ # a corresponding name.
86
+ #
87
+ # === Process:
88
+ #
89
+ # 1. All autotest/discover.rb files loaded.
90
+ # 2. Those procs determine your styles (eg ["rails", "rspec"]).
91
+ # 3. Require file by sorting styles and joining (eg 'autotest/rails_rspec').
92
+ # 4. Invoke run method on appropriate class (eg Autotest::RailsRspec.run).
93
+ #
94
+ # === Example autotest/discover.rb:
95
+ #
96
+ # Autotest.add_discovery do
97
+ # "rails" if File.exist? 'config/environment.rb'
98
+ # end
99
+ #
100
+
101
+ def self.autodiscover
102
+ style = []
103
+
104
+ $:.push(*Dir["vendor/plugins/*/lib"])
105
+ paths = $:.dup
106
+
107
+ begin
108
+ require 'rubygems'
109
+ paths.push(*Gem.latest_load_paths)
110
+ rescue LoadError => e
111
+ # do nothing
112
+ end
113
+
114
+ paths.each do |d|
115
+ f = File.join(d, 'autotest', 'discover.rb')
116
+ load f if File.exist? f
117
+ end
118
+
119
+ @@discoveries.map { |proc| proc.call }.flatten.compact.sort.uniq
120
+ end
61
121
 
62
122
  def self.run
63
123
  new.run
@@ -97,6 +157,8 @@ class Autotest
97
157
  hook :initialize
98
158
  end
99
159
 
160
+ # Repeatedly run failed tests, then all tests, then
161
+ # wait for changes and carry on until killed.
100
162
  def run
101
163
  hook :run
102
164
  reset
@@ -122,6 +184,7 @@ class Autotest
122
184
  hook :quit
123
185
  end
124
186
 
187
+ # Keep running the tests after a change, until all pass.
125
188
  def get_to_green
126
189
  until all_good do
127
190
  run_tests
@@ -129,6 +192,8 @@ class Autotest
129
192
  end
130
193
  end
131
194
 
195
+ # Look for files to test then run the tests and
196
+ # handle the results.
132
197
  def run_tests
133
198
  find_files_to_test # failed + changed/affected
134
199
  cmd = make_test_cmd @files_to_test
@@ -179,10 +244,16 @@ class Autotest
179
244
  end
180
245
  end
181
246
 
247
+ # If there are no files left to test
248
+ # (because they've all passed),
249
+ # then all is good.
182
250
  def all_good
183
251
  @files_to_test.empty?
184
252
  end
185
253
 
254
+ # Convert a path in a string, s, into a
255
+ # class name, changing underscores to CamelCase,
256
+ # etc
186
257
  def path_to_classname(s)
187
258
  sep = File::SEPARATOR
188
259
  f = s.sub(/^test#{sep}/, '').sub(/\.rb$/, '').split(sep)
@@ -191,6 +262,7 @@ class Autotest
191
262
  f.join('::')
192
263
  end
193
264
 
265
+
194
266
  def consolidate_failures(failed)
195
267
  filters = Hash.new { |h,k| h[k] = [] }
196
268
 
@@ -207,6 +279,9 @@ class Autotest
207
279
  return filters
208
280
  end
209
281
 
282
+ # Find the files to process, ignoring temporary files,
283
+ # source configuration management files, etc., and return
284
+ # a Hash mapping filename to modification time.
210
285
  def find_files
211
286
  result = {}
212
287
  Find.find '.' do |f|
@@ -223,6 +298,11 @@ class Autotest
223
298
  return result
224
299
  end
225
300
 
301
+ # Find the files which have been modified, update
302
+ # the recorded timestamps, and use this to update
303
+ # the files to test. Returns true if any file is
304
+ # newer than the previously recorded most recent
305
+ # file.
226
306
  def find_files_to_test(files=find_files)
227
307
  updated = files.select { |filename, mtime|
228
308
  @files[filename] < mtime
@@ -246,6 +326,8 @@ class Autotest
246
326
  @last_mtime > previous
247
327
  end
248
328
 
329
+ # Check results for failures, set the "bar" to red or
330
+ # green, and if there are failures record this.
249
331
  def handle_results(results)
250
332
  failed = results.scan(/^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)/)
251
333
  completed = results =~ /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/
@@ -257,6 +339,7 @@ class Autotest
257
339
  @tainted = true unless @files_to_test.empty?
258
340
  end
259
341
 
342
+ # Generate the commands to test the supplied files
260
343
  def make_test_cmd files_to_test
261
344
  cmds = []
262
345
  full, partial = files_to_test.partition { |k,v| v.empty? }
@@ -270,15 +353,18 @@ class Autotest
270
353
  cmds << "#{ruby} -I#{@libs} #{klass} -n \"/^(#{Regexp.union(*methods).source})$/\" | #{unit_diff}"
271
354
  end
272
355
 
273
- return cmds.join('; ')
356
+ return cmds.join("#{SEP} ")
274
357
  end
275
358
 
359
+ # Rerun the tests from cold (reset state)
276
360
  def rerun_all_tests
277
361
  reset
278
362
  run_tests
279
363
  hook :all_good if all_good
280
364
  end
281
365
 
366
+ # Clear all state information about test failures
367
+ # and whether interrupts will kill autotest.
282
368
  def reset
283
369
  @interrupted = @wants_to_quit = false
284
370
  @files.clear
@@ -289,6 +375,7 @@ class Autotest
289
375
  hook :reset
290
376
  end
291
377
 
378
+ # determine and return the path of the ruby executable.
292
379
  def ruby
293
380
  ruby = File.join(Config::CONFIG['bindir'],
294
381
  Config::CONFIG['ruby_install_name'])
@@ -300,6 +387,9 @@ class Autotest
300
387
  return ruby
301
388
  end
302
389
 
390
+
391
+ # Return the name of the file with the tests for
392
+ # filename.
303
393
  def tests_for_file(filename)
304
394
  result = @test_mappings.find { |file_re, ignored| filename =~ file_re }
305
395
  result = result.nil? ? [] : Array(result.last.call(filename, $~))
@@ -309,6 +399,8 @@ class Autotest
309
399
  result.sort.uniq
310
400
  end
311
401
 
402
+ # Sleep then look for files to test, until there
403
+ # are some.
312
404
  def wait_for_changes
313
405
  hook :waiting
314
406
  begin
@@ -331,6 +423,8 @@ class Autotest
331
423
  end
332
424
  end
333
425
 
426
+ # Add the supplied block to the available hooks, with
427
+ # the given name.
334
428
  def self.add_hook(name, &block)
335
429
  HOOKS[name] << block
336
430
  end
@@ -7,7 +7,7 @@ require 'autotest'
7
7
  #
8
8
  # Contributed by Geoffrey Grosenbach http://nubyonrails.com
9
9
 
10
- class CampingAutotest < Autotest
10
+ class Autotest::Camping < Autotest
11
11
 
12
12
  def initialize # :nodoc:
13
13
  super
@@ -0,0 +1,6 @@
1
+ Autotest.add_discovery do
2
+ style = []
3
+ style << "rails" if File.exist? 'config/environment.rb'
4
+ style << "camping" if File.exist? 'test/camping_test_case.rb'
5
+ style
6
+ end
@@ -3,8 +3,14 @@
3
3
  #
4
4
 
5
5
  module Autotest::Emacs
6
+ @@client_cmd = 'emacsclient -e'
7
+
8
+ def self.command= o
9
+ @@client_cmd = o
10
+ end
11
+
6
12
  def self.emacs_autotest status
7
- `emacsclient -e \"(autotest-update '#{status})\"`
13
+ `#{@@client_cmd} \"(autotest-update '#{status})\"`
8
14
  end
9
15
 
10
16
  Autotest.add_hook :run_command do |at|
@@ -1,6 +1,6 @@
1
1
  require 'autotest'
2
2
 
3
- class RailsAutotest < Autotest
3
+ class Autotest::Rails < Autotest
4
4
 
5
5
  def initialize # :nodoc:
6
6
  super
@@ -54,10 +54,13 @@ class RailsAutotest < Autotest
54
54
  }
55
55
  end
56
56
 
57
+ # Given the string filename as the path, determine
58
+ # the corresponding tests for it, in an array.
57
59
  def tests_for_file(filename)
58
60
  super.select { |f| @files.has_key? f }
59
61
  end
60
62
 
63
+ # Convert the pathname s to the name of class.
61
64
  def path_to_classname(s)
62
65
  sep = File::SEPARATOR
63
66
  f = s.sub(/^test#{sep}((unit|functional|integration|views|controllers|helpers)#{sep})?/, '').sub(/\.rb$/, '').split(sep)
@@ -13,9 +13,9 @@
13
13
  ########################################################################
14
14
  # Example Test Matrix Specification:
15
15
  #
16
- # matrix :example, :edge1, edge2, :edge3, ...
17
- # action :action1, :new, :err, :err, ...
18
- # action :action2, :del, :err, :na, ...
16
+ # matrix :example, :edge1, :edge2, :edge3, ...
17
+ # action :action1, :OK, :e_NF, :mod, ...
18
+ # action :action2, :OK, :e_RO, :na, ...
19
19
  # action ...
20
20
  #
21
21
  ########################################################################
@@ -40,6 +40,11 @@
40
40
  #
41
41
  # Use :na to specify an inapplicable edge case for that action.
42
42
  #
43
+ # Use :OK to specify the standard positive state. It is equivalent to
44
+ # a result with the same name as the action. (eg
45
+ # matrix_test_index). This cleans up the matrix a lot and allows for
46
+ # narrower and more readable columns.
47
+ #
43
48
  # Edge cases specific to an action that fall outside the matrix are
44
49
  # regular tests.
45
50
  #
@@ -52,7 +57,8 @@
52
57
  # + There is one "setup" method per action: matrix_setup_#{action}(setup, expect)
53
58
  # + There is one "test" method per result: matrix_test_#{result}(setup)
54
59
  #
55
- # Thus, for the example above, the top left-most test will end up calling:
60
+ # Thus, for the matrix "example" above, the top left-most test will
61
+ # end up calling:
56
62
  #
57
63
  # matrix_init_example(:edge1)
58
64
  # matrix_setup_action1(:edge1, :new)
@@ -72,11 +78,12 @@ module FunctionalTestMatrix
72
78
  matrix = @@matrix # bind to local scope for define_method closure
73
79
 
74
80
  testcases.each do |setup, expected|
75
- define_method "test_#{action}_#{setup}" do
81
+ expected_action = expected == :OK ? action : expected
82
+ define_method "test_#{matrix}_#{action}_#{setup}" do
76
83
  @action = action
77
84
  send "matrix_init_#{matrix}", *setup.to_s.split(/_/).map {|c| c.intern }
78
85
  send "matrix_setup_#{action}", setup, expected
79
- send "matrix_test_#{expected}", setup
86
+ send "matrix_test_#{expected_action}", setup
80
87
  end
81
88
  end
82
89
  end
data/lib/unit_diff.rb CHANGED
@@ -105,6 +105,8 @@ class UnitDiff
105
105
  return data, footer
106
106
  end
107
107
 
108
+ # Parses a single diff recording the header and what
109
+ # was expected, and what was actually obtained.
108
110
  def parse_diff(result)
109
111
  header = []
110
112
  expect = []
data/lib/zentest.rb CHANGED
@@ -56,7 +56,7 @@ end
56
56
 
57
57
  class ZenTest
58
58
 
59
- VERSION = '3.5.2'
59
+ VERSION = '3.6.0'
60
60
 
61
61
  include ZenTestMapping
62
62
 
@@ -36,7 +36,9 @@ class TestAutotest < Test::Unit::TestCase
36
36
  @outer_test = 'test/test_outer.rb'
37
37
  @inner_test_class = "TestOuter::TestInner"
38
38
 
39
- @a = Object.const_get(self.class.name[4..-1]).new
39
+ klassname = self.class.name.sub(/^Test/, '')
40
+ klassname.sub!(/^(\w+)(Autotest)$/, '\2::\1') unless klassname == "Autotest"
41
+ @a = klassname.split(/::/).inject(Object) { |k,n| k.const_get(n) }.new
40
42
  @a.output = StringIO.new
41
43
  @a.files.clear
42
44
  @a.files[@impl] = Time.at(1)
@@ -1,6 +1,6 @@
1
1
  require 'test/unit' if $0 == __FILE__
2
2
  require 'test/test_autotest'
3
- require 'rails_autotest'
3
+ require 'autotest/rails'
4
4
 
5
5
  class TestRailsAutotest < TestAutotest
6
6
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.9
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ZenTest
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.5.2
7
- date: 2007-04-30 00:00:00 -07:00
6
+ version: 3.6.0
7
+ date: 2007-05-25 00:00:00 -07:00
8
8
  summary: "ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails."
9
9
  require_paths:
10
10
  - lib
@@ -48,6 +48,8 @@ files:
48
48
  - example_dot_autotest.rb
49
49
  - lib/autotest.rb
50
50
  - lib/autotest/autoupdate.rb
51
+ - lib/autotest/camping.rb
52
+ - lib/autotest/discover.rb
51
53
  - lib/autotest/emacs.rb
52
54
  - lib/autotest/fixtures.rb
53
55
  - lib/autotest/growl.rb
@@ -58,15 +60,13 @@ files:
58
60
  - lib/autotest/migrate.rb
59
61
  - lib/autotest/notify.rb
60
62
  - lib/autotest/pretty.rb
63
+ - lib/autotest/rails.rb
61
64
  - lib/autotest/redgreen.rb
62
65
  - lib/autotest/screen.rb
63
66
  - lib/autotest/shame.rb
64
67
  - lib/autotest/snarl.rb
65
68
  - lib/autotest/timestamp.rb
66
- - lib/camping_autotest.rb
67
69
  - lib/functional_test_matrix.rb
68
- - lib/rails_autotest.rb
69
- - lib/rspec_rails_autotest.rb
70
70
  - lib/ruby_fork.rb
71
71
  - lib/test/rails.rb
72
72
  - lib/test/rails/controller_test_case.rb
@@ -105,10 +105,15 @@ test_files:
105
105
  - test/test_zentest.rb
106
106
  - test/test_zentest_assertions.rb
107
107
  - test/test_zentest_mapping.rb
108
- rdoc_options: []
109
-
110
- extra_rdoc_files: []
111
-
108
+ rdoc_options:
109
+ - --main
110
+ - README.txt
111
+ extra_rdoc_files:
112
+ - History.txt
113
+ - LinuxJournalArticle.txt
114
+ - Manifest.txt
115
+ - README.txt
116
+ - example.txt
112
117
  executables:
113
118
  - autotest
114
119
  - multiruby
@@ -129,5 +134,5 @@ dependencies:
129
134
  requirements:
130
135
  - - ">="
131
136
  - !ruby/object:Gem::Version
132
- version: 1.2.0
137
+ version: 1.2.1
133
138
  version:
@@ -1,119 +0,0 @@
1
- # (c) Copyright 2006 Nick Sieger <nicksieger@gmail.com>
2
- #
3
- # Permission is hereby granted, free of charge, to any person
4
- # obtaining a copy of this software and associated documentation files
5
- # (the "Software"), to deal in the Software without restriction,
6
- # including without limitation the rights to use, copy, modify, merge,
7
- # publish, distribute, sublicense, and/or sell copies of the Software,
8
- # and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18
- # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19
- # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
-
23
- require 'autotest'
24
-
25
- class RspecRailsAutotest < Autotest
26
- attr_accessor :spec_command
27
-
28
- def initialize # :nodoc:
29
- @spec_command = "spec --diff unified"
30
- super
31
- @exceptions = %r%^\./(?:coverage|db|doc|log|public|script|vendor)%
32
- end
33
-
34
- def tests_for_file(filename)
35
- case filename
36
- when %r%^spec/fixtures/(.*)s.yml% then
37
- ["spec/models/#{$1}_spec.rb",
38
- "spec/controllers/#{$1}_controller_spec.rb"]
39
- when %r%^spec/models/.*rb$% then
40
- [filename]
41
- when %r%^spec/controllers/.*\.rb$% then
42
- [filename]
43
- # when %r%^spec/acceptance/.*\.rb$% then
44
- # [filename]
45
- when %r%^app/models/(.*)\.rb$% then
46
- ["spec/models/#{$1}_spec.rb"]
47
- when %r%^app/helpers/application_helper.rb% then
48
- @files.keys.select { |f|
49
- f =~ %r%^spec/controllers/.*_spec\.rb$%
50
- }
51
- when %r%^app/helpers/(.*)_helper.rb% then
52
- ["spec/controllers/#{$1}_controller_spec.rb"]
53
- when %r%^app/controllers/application.rb$% then
54
- @files.keys.select { |f|
55
- f =~ %r%^spec/controllers/.*_spec\.rb$%
56
- }
57
- when %r%^app/controllers/(.*)\.rb$% then
58
- ["spec/controllers/#{$1}_spec.rb"]
59
- when %r%^app/views/layouts/% then
60
- []
61
- when %r%^app/views/(.*)/% then
62
- ["spec/controllers/#{$1}_controller_spec.rb"]
63
- when %r%^config/routes.rb$% then
64
- @files.keys.select do |f|
65
- f =~ %r%^spec/controllers/.*_spec\.rb$%
66
- end
67
- when %r%^spec/spec_helper.rb%,
68
- %r%^config/((boot|environment(s/test)?).rb|database.yml)% then
69
- @files.keys.select do |f|
70
- f =~ %r%^spec/(models|controllers)/.*_spec\.rb$%
71
- end
72
- else
73
- @output.puts "Dunno! #{filename}" if $TESTING
74
- []
75
- end.uniq.select { |f| @files.has_key? f }
76
- end
77
-
78
- def handle_results(results)
79
- failed = results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
80
- @files_to_test = consolidate_failures failed
81
- unless @files_to_test.empty? then
82
- hook :red
83
- else
84
- hook :green
85
- end unless $TESTING
86
- @tainted = true unless @files_to_test.empty?
87
- end
88
-
89
- def consolidate_failures(failed)
90
- filters = Hash.new { |h,k| h[k] = [] }
91
- failed.each do |spec, failed_trace|
92
- @files.keys.select{|f| f =~ /spec\//}.each do |f|
93
- if failed_trace =~ Regexp.new(f)
94
- filters[f] << spec
95
- break
96
- end
97
- end
98
- end
99
- return filters
100
- end
101
-
102
- def make_test_cmd(files_to_test)
103
- cmds = []
104
- full, partial = files_to_test.partition { |k,v| v.empty? }
105
-
106
- unless full.empty? then
107
- classes = full.map {|k,v| k}.flatten.join(' ')
108
- cmds << "#{spec_command} #{classes}"
109
- end
110
-
111
- partial.each do |klass, methods|
112
- cmds.push(*methods.map { |meth|
113
- "#{spec_command} -s #{meth.inspect} #{klass}"
114
- })
115
- end
116
-
117
- return cmds.join('; ')
118
- end
119
- end