Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tag: v2.0.0.beta.10
Fetching contributors…

Cannot retrieve contributors at this time

58 lines (48 sloc) 1.326 kB
# Run me with:
#
# $ watchr specs.watchr
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def all_test_files
Dir['spec/**/*_spec.rb']
end
def run_test_matching(thing_to_match)
matches = all_test_files.grep(/#{thing_to_match}/i)
if matches.empty?
puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}"
else
run matches.join(' ')
end
end
def run(files_to_run)
puts("Running: #{files_to_run}")
system("clear;rspec -cfs #{files_to_run}")
no_int_for_you
end
def run_all
run(all_test_files.join(' '))
end
# --------------------------------------------------
# Watchr Rules
# --------------------------------------------------
watch('^spec/(.*)_spec\.rb') { run_all }
watch('^lib/(.*)\.rb') { run_all }
# --------------------------------------------------
# Signal Handling
# --------------------------------------------------
def no_int_for_you
@sent_an_int = nil
end
Signal.trap 'INT' do
if @sent_an_int then
puts " A second INT? Ok, I get the message. Shutting down now."
exit
else
puts " Did you just send me an INT? Ugh. I'll quit for real if you do it again."
@sent_an_int = true
Kernel.sleep 1.5
run_all
end
end
# vim:ft=ruby
Jump to Line
Something went wrong with that request. Please try again.