Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

watchr vs autotest for rails apps

So I've been having a lot of problems lately getting autotest to work in my rails3 app. Rather than continuing to fiddle with it in hopes of ever getting it to work I started looking into alternatives. Right now it seems like watchr is a great alternative. But I wanted to ask, are there any particular advantages to using one over the other? The most obvious I can tell is that watchr takes a little bit more to setup. However, after that it seems to "just work". So the tradeoff seems well worth it to me but what are some other pros/cons?

Also, I'm not too familiar with what spork is or how it works, but can watchr be used with spork and let me gain the advantage of tests in rails running much faster?

like image 528
Lan Avatar asked Dec 10 '10 10:12

Lan


1 Answers

I recently had a problem with autotest, because it's nasty if you don't use the file structure it expects. Therefore I gave watchr a try an I'm very pleased.

If you just want to run your tests automatically after change, both tools are equal. Autotest will work out of the box in a rails project, while watchr needs a config file to run. So there is a little overhead for watchr. However, there are several projects out there who already configured watchr to behave like autotest.

As soon as you want to use a customized command every time a specific file is changed, watchr shows it's strength. For example, running rake annotate every time the schema.rb changes or generating updated docs every time important files are changed.

Such behaviour is possible in watchr via it's simple configuration syntax: watch('regular expression') {|match_data| your_command match_data[0]}. To run all specs in color you call watchr config_file.rb, while config_file.rb contains

watch ('spec/.*_spec\.rb') {|md| system "rspec -c spec/"}

Since watchr seems to work with nestor (which is similar to spork), it should be possible to integrate spork as well.

To sum up: watchr is much more flexible than autotest, but needs some configuration to start with. watchr should be able to work nicely with spork.

like image 127
Florian Pilz Avatar answered Sep 21 '22 03:09

Florian Pilz