Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created January 19, 2011 08:51
Show Gist options
  • Save ajsharp/785888 to your computer and use it in GitHub Desktop.
Save ajsharp/785888 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
begin
require 'rev'
rescue LoadError
puts "############## WARNING!!! ##############"
puts "You do not have the rev gem installed.\nIt is highly recommended to install this."
puts "The rev gem uses filesystem events rather than cpu polling to see if files have changed."
puts "\n"
puts "Please run `gem install rev` to install"
puts "\n"
puts "########################################"
end
puts "\n### Watching specs###\n"
def cmd() 'rspec '; end
def run_all_specs
system(cmd + 'spec')
end
def run_spec(spec)
if File.exists?(spec)
system "clear"
puts "Running #{spec}"
system(cmd + spec)
else
puts "Cannot find spec file #{spec}"
end
end
watch('^spec\/.*\/.*_spec\.rb') {|md| run_spec(md[0]) }
watch('^spec\/.*_spec\.rb') {|md| run_spec(md[0]) }
watch('^lib/(.*)\.rb') {|md| run_spec("spec/#{md[1]}_spec.rb") }
watch('^lib/.*\/(.*)\.rb') {|md| run_spec("spec/#{md[1]}_spec.rb") }
# Ctrl-\
Signal.trap('QUIT') do
puts "\n### Running all specs###\n"
run_all_specs
end
# Ctrl-C
Signal.trap('INT') { abort("\n") }.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment