[rspec-users] [RSpec][OT] have autospec just run changed files

Stephen Eley sfeley at gmail.com
Fri Feb 20 15:33:12 EST 2009

On Fri, Feb 20, 2009 at 2:33 PM, Peter Jaros <peter.a.jaros at gmail.com> wrote:
> Other than that, I can't think of a way to do it short of writing your
> own autospec style and overriding the #run algorithm.

Which is almost exactly what I was about to suggest.  >8->  Only you
don't have to override #run, you can just fake it out at the point
where it reruns all tests and skip that part.

1.) Make an autotest directory in your project.
2.) Add a file 'discover.rb' and include the following:
    Autotest.add_discovery { "mabey" }  # Or whatever you want to call
your specialization
3.) If you're using Rails and RSpec, you then need to add a file
'mabey_rails_rspec.rb'.  If only RSpec, just 'mabey_rspec.rb'.  If
you're using Merb and RSpec, it needs to be 'mabey_merb_rspec.rb'.
You get the point.  Autotest's class and file discovery is just wonky.
 In it:

    class Autotest::MabeyRailsRspec < Autotest::RailsRspec  # Or
whatever your appropriate chain is
      def rerun_all_tests

I figured that out from reading the Autotest code a while back and
figuring out how to fix problems with Merb, RSpec and Cucumber.  My
conclusion is that Autotest is *sort of* elegant in its own way, but
that way appears to be based on the standards of someone high on a
cocktail of LSD and laudanum.  It uses convention over
configuration...sort of...except that you have to configure the
conventions first.  And then too much is hardcoded, and its
inheritance and class-naming structure means you have to predict every
possible combination of frameworks in advance.

Someone needs to either hit it with the design pattern stick or write
a new one.  Maybe I will, the next time I manage to take a couple days

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list