<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,8 @@
-# Adapted from Autotest::Rails
+# Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's.
 require 'autotest'
 
+class RspecCommandError &lt; StandardError; end
+
 class Autotest::MerbRspec &lt; Autotest
   
   # +model_tests_dir+::      the directory to find model-centric tests
@@ -23,7 +25,7 @@ class Autotest::MerbRspec &lt; Autotest
     # Any changes to a file in the root of the 'lib' directory will run any 
     # model test with a corresponding name.
     add_mapping %r%^lib\/.*\.rb% do |filename, _|
-      files_matching Regexp.new(&quot;^#{model_test_for(filename)}$&quot;)
+      files_matching %r%#{model_test_for(filename)}$%
     end
     
     add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
@@ -102,29 +104,51 @@ class Autotest::MerbRspec &lt; Autotest
     end
   end
   
-  ##
-  # Methods below this point are adapted from Auotest::Rspec
+  def failed_results(results)
+    results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
+  end
+
+  def handle_results(results)
+    @failures = failed_results(results)
+    @files_to_test = consolidate_failures @failures
+    unless $TESTING
+      if @files_to_test.empty?
+        hook :green
+      else
+        hook :red
+      end
+    end
+    @tainted = true unless @files_to_test.empty?
+  end
   
   def consolidate_failures(failed)
     filters = Hash.new { |h,k| h[k] = [] }
     failed.each do |spec, failed_trace|
-      if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
-        filters[f] &lt;&lt; spec
-        break
+      find_files.keys.select { |f| f =~ /spec\// }.each do |f|
+        if failed_trace =~ Regexp.new(f)
+          filters[f] &lt;&lt; spec
+          break
+        end
       end
     end
-    return filters
+    filters
   end
 
   def make_test_cmd(files_to_test)
-    return &quot;#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}&quot;
+    [
+      ruby, 
+      &quot;-S&quot;, 
+      spec_command, 
+      add_options_if_present, 
+      files_to_test.keys.flatten.join(' ')
+    ].join(&quot; &quot;)
   end
   
   def add_options_if_present
     File.exist?(&quot;spec/spec.opts&quot;) ? &quot;-O spec/spec.opts &quot; : &quot;&quot;
   end
 
-  # Finds the proper spec command to use.  Precendence is set in the
+  # Finds the proper spec command to use. Precendence is set in the
   # lazily-evaluated method spec_commands.  Alias + Override that in
   # ~/.autotest to provide a different spec command then the default
   # paths provided.
@@ -134,7 +158,7 @@ class Autotest::MerbRspec &lt; Autotest
 
       raise RspecCommandError, &quot;No spec command could be found!&quot; unless @spec_command
 
-      @spec_command.gsub! File::SEPARATOR, separator if separator
+      @spec_command.gsub!(File::SEPARATOR, separator) if separator
     end
     @spec_command
   end
@@ -182,7 +206,7 @@ private
   #   =&gt; &quot;form_view_spec.rb&quot; # If you're running a RSpec-like suite
   def test_for(filename, kind_of_test) # :nodoc:
     name  = [filename]
-    name &lt;&lt; kind_of_test.to_s unless kind_of_test == :view
+    name &lt;&lt; kind_of_test.to_s if kind_of_test == :view
     name &lt;&lt; &quot;spec&quot;
     return name.join(&quot;_&quot;) + &quot;.rb&quot;
   end</diff>
      <filename>autotest/merb_rspec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>adfa6533e6a81eb7063b1ea9948fe2346df587bc</id>
    </parent>
  </parents>
  <author>
    <name>James Herdman</name>
    <email>james.herdman@gmail.com</email>
  </author>
  <url>http://github.com/meekish/collective/commit/eeef91c80dd73511d66cb184d7cb7ac674de9dbd</url>
  <id>eeef91c80dd73511d66cb184d7cb7ac674de9dbd</id>
  <committed-date>2008-04-04T14:46:06-07:00</committed-date>
  <authored-date>2008-04-04T14:46:06-07:00</authored-date>
  <message>Bring Autotest support inline with Edge Merb</message>
  <tree>db5a1162c4bbda5ab9ca5781ab0787878a42614a</tree>
  <committer>
    <name>James Herdman</name>
    <email>james.herdman@gmail.com</email>
  </committer>
</commit>
