Ben Mabey
2009-Feb-20 18:34 UTC
[rspec-users] [RSpec][OT] have autospec just run changed files
Hello all, Is there a way to have autospec and/or RSpactor just run the specs for the files that have changed and not run the entire spec suite afterwards? If you start autospec with -f it will wait for a change but it will then run the entire suite after the individual one passes. The project that I am working on now has a spec suite that is too long for the normal autospec cycle. However, I like having that tight feedback loop for the files I touch. Any ideas? Thanks, Ben
Peter Jaros
2009-Feb-20 19:33 UTC
[rspec-users] [RSpec][OT] have autospec just run changed files
I don''t know about RSpactor, but autospec will keep track of failing specs and re-run them along with changed specs and specs for changed files. It won''t run the entire suite until everything has passed. You could temporarily add a dummy example somewhere in your suite which always fails. That way autospec will never think it''s ready to run the whole suite. 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. Peeja On Fri, Feb 20, 2009 at 1:34 PM, Ben Mabey <ben at benmabey.com> wrote:> Hello all, > Is there a way to have autospec and/or RSpactor just run the specs for the > files that have changed and not run the entire spec suite afterwards? If > you start autospec with -f it will wait for a change but it will then run > the entire suite after the individual one passes. The project that I am > working on now has a spec suite that is too long for the normal autospec > cycle. However, I like having that tight feedback loop for the files I > touch. Any ideas? > > Thanks, > Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Stephen Eley
2009-Feb-20 20:33 UTC
[rspec-users] [RSpec][OT] have autospec just run changed files
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 reset end end 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 off. -- Have Fun, Steve Eley (sfeley at gmail.com) ESCAPE POD - The Science Fiction Podcast Magazine http://www.escapepod.org
Ben Mabey
2009-Feb-21 06:33 UTC
[rspec-users] [RSpec][OT] have autospec just run changed files
Stephen Eley wrote:> 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 > reset > end > end > > 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 > off. > > > >Thanks a lot! I couldn''t get your exact way to work so I ended up monkey patching Autotest with your #rerun_all_tests in my .autotest file. So far it is working great. Thanks again! -Ben
David Chelimsky
2009-Feb-22 16:39 UTC
[rspec-users] [RSpec][OT] have autospec just run changed files
On Sat, Feb 21, 2009 at 12:33 AM, Ben Mabey <ben at benmabey.com> wrote:> Stephen Eley wrote: >> >> 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 >> reset >> end >> end >> >> 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 >> off. >> >> >> >> > > Thanks a lot! > I couldn''t get your exact way to work so I ended up monkey patching Autotest > with your #rerun_all_tests in my .autotest file. So far it is working > great. Thanks again!I wonder if this might be a better approach to dealing with Autotest extensions. There seems to be an issue with Autotest extensions and ruby 1.9 (1.9 confusing bin/autotest and an ./autoest directory). We could do the following without putting any burden on Autotest: Move what is now in lib/autotest/rspec.rb (lib/autotest/rails_rspec.rb in rspec-rails) to something like lib/spec/autotest.rb, which you''d have to require in .autotest. Done! Unless I''m missing something. This would put an extra step to using autotest, but it solves the 1.9 problem and it also makes it so we no longer need autospec, which I wouldn''t mind getting rid of in the long run. Thoughts?> > -Ben > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >