Skip to content

Instantly share code, notes, and snippets.

@thirdreplicator
Created April 18, 2011 07:17
Show Gist options
  • Save thirdreplicator/924934 to your computer and use it in GitHub Desktop.
Save thirdreplicator/924934 to your computer and use it in GitHub Desktop.
Handy directory watcher for running tests in the background.
require 'directory_watcher'
# gem 'directory_watcher.rb'
# gem 'rev'
#command = 'rspec --drb --color spec'
command = "cucumber --drb -f html -o tmp/cuke.html -f progress -o tmp/progress.txt features"
dw = DirectoryWatcher.new '.', :pre_load => true, :scanner => :rev
dw.glob = '**/*.{rb,feature,haml,erb}'
dw.reset true
dw.interval = 1.0
dw.stable = 1.0
system(command)
dw.add_observer do |*args|
args.each do |event|
#puts event if event.to_s =~ /stable/
system(command) if event.to_s =~ /stable/
end
end
dw.start
gets # when the user hits "enter" the script will terminate
dw.stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment