Skip to content

Instantly share code, notes, and snippets.

@skuroki
Forked from rud/watchr-runner.rb
Created November 2, 2011 09:19
Show Gist options
  • Save skuroki/1333244 to your computer and use it in GitHub Desktop.
Save skuroki/1333244 to your computer and use it in GitHub Desktop.
watchr for rspec
def run(cmd)
puts(cmd)
system(cmd)
puts 'Finished. ' + Time.now.to_s
end
def run_single_spec (*spec)
spec = spec.join(' ')
run "rspec -bX #{spec}"
end
# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch( '^spec/requests/.*_spec\.rb' ) { |m| run_single_spec(m[0]) }
watch( '^spec/.*_spec\.rb' ) { |m| run_single_spec(m[0]) }
watch( '^app/(.*)\.rb' ) { |m| run_single_spec("spec/%s_spec.rb" % m[1]) }
watch( '^app/views/(.*)\.erb' ) { |m| run_single_spec("spec/views/%s.erb_spec.rb" % m[1]) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment