public
Description: Kickstart your Rails app with a blank-slate project configured for RSpec, Haml
Homepage:
Clone URL: git://github.com/mislav/kickstart-rails.git
add comments on why I monkeypatched Autotest
Mislav Marohnić (author)
Wed Apr 30 21:31:44 -0700 2008
commit  868ecd0c71e201615402dcc2177d0e2432087d65
tree    21cb7562b7c48a7cc5f2a5c6fbaa745bc4b30115
parent  dc90e62128e50ef8937f2800a10efc4f0a857e98
...
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
 
 
 
 
 
15
16
17
18
19
20
 
 
21
22
23
...
1
2
3
4
5
6
7
8
 
 
 
 
 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
0
@@ -1,23 +1,26 @@
0
 # vi:ft=ruby:
0
 Autotest.add_hook :initialize do |at|
0
   
0
+  # add these to ignore list
0
   %w{ vendor/gems/ .git stories/ Rakefile Capfile README .autotest spec/spec.opts spec/rcov.opts }.each do |exception|
0
     at.add_exception exception
0
   end
0
   
0
-
0
-  at.add_mapping(/spec\/defaults.rb/) do |f, _|
0
-    at.files_matching %r%^spec/(controllers|helpers|lib|models|views)/.*\.rb$%
0
-  end
0
-
0
 end
0
 
0
+# ugh, we have to monkeypatch Autotest ...
0
+# the regexp it generates for the exception list just matches too much
0
+# 
0
+# SOLUTION: wrap it up in another regexp that anchors the whole expression to
0
+# the beginning of the path
0
 class Autotest
0
   def exceptions_non_greedy
0
     unless defined? @exceptions then
0
       if @exception_list.empty? then
0
         @exceptions = nil
0
       else
0
+        # old (BAD):
0
+        # @exceptions = Regexp.union(*@exception_list)
0
         @exceptions = /^\.\/#{Regexp.union(*@exception_list)}/
0
       end
0
     end

Comments

jamesking Fri May 23 14:46:25 -0700 2008

Hi Mislav, I came across your Autotest monkeypatch while searching for a solution to a problem I was having where Autotest was ignoring templates and their corresponding specs in the app/views/public and spec/views/public directories of my rails app. Your patch worked for me, so thanks!

I was wondering if it would be proper to submit this patch to the ZenTest developers?

mislav Sat May 24 06:54:54 -0700 2008

Yeah, I think the bug is serious enough. If you’re volunteering to do it, go right ahead :) I haven’t had time since I fixed this for myself.

jamesking Sat May 24 07:32:24 -0700 2008

I have submitted a bug report.