Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fearoffish/118573 to your computer and use it in GitHub Desktop.
Save fearoffish/118573 to your computer and use it in GitHub Desktop.
Quick hack of a script to replace autotest temporarily
#!/usr/bin/env ruby
require 'rubygems'
require 'directory_watcher'
puts "Watching #{Dir.pwd}/test/**/*.rb'"
dw = DirectoryWatcher.new "#{Dir.pwd}/test", :glob => '**/*.rb', :interval => 2
dw.add_observer do |*args|
args.each do |event|
case event.type
when :modified
if event.path.split('/').last.split('.').first.match(/.*_test/)
puts "Re-running tests in #{event.path.split('/').last.split('.').first}"
system "ruby -Ilib:test '/Library/Ruby/Gems/1.8/gems/rake-0.8.5/lib/rake/rake_test_loader.rb' #{event.path}"
else
puts "Skipping non-test file"
end
end
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