Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 39 lines (31 sloc) 0.777 kB
ebb5445 @jnunemaker Added watchr file for running tests.
authored
1 def run(cmd)
2 puts(cmd)
3 output = ""
4 IO.popen(cmd) do |com|
5 com.each_char do |c|
6 print c
7 output << c
8 $stdout.flush
9 end
10 end
9031240 @jnunemaker Removing growl from watchr.
authored
11 output
ebb5445 @jnunemaker Added watchr file for running tests.
authored
12 end
13
14 def run_test_file(file)
15 run %Q(ruby -I"lib:test" -rubygems #{file})
16 end
17
18 def run_all_tests
19 run "rake test"
20 end
21
22 def related_test_files(path)
23 Dir['test/**/*.rb'].select { |file| file =~ /test_#{File.basename(path)}/ }
24 end
25
26 watch('test/test_helper\.rb') { system('clear'); run_all_tests }
e15c6a5 @jnunemaker Watchr fix for nested test files.
authored
27 watch('test/.*test_.*\.rb') { |m| system('clear'); run_test_file(m[0]) }
ebb5445 @jnunemaker Added watchr file for running tests.
authored
28 watch('lib/.*') { |m| related_test_files(m[0]).each { |file| run_test_file(file) } }
29
30 # Ctrl-\
31 Signal.trap('QUIT') do
32 puts " --- Running all tests ---\n\n"
33 run_all_tests
34 end
35
36 # Ctrl-C
37 Signal.trap('INT') { abort("\n") }
38
Something went wrong with that request. Please try again.