Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 53 lines (43 sloc) 1.188 kb
6f5dbda @jnunemaker Added watchr goodies.
jnunemaker authored
1 def growl(title, msg, img)
2 %x{growlnotify -m #{ msg.inspect} -t #{title.inspect} --image ~/.watchr/#{img}.png}
3 end
4
5 def form_growl_message(str)
6 results = str.split("\n").last
7 if results =~ /[1-9]\s(failure|error)s?/
8 growl "Test Results", "#{results}", "fail"
9 elsif results != ""
10 growl "Test Results", "#{results}", "pass"
11 end
12 end
13
14 def run(cmd)
15 puts(cmd)
16 output = ""
17 IO.popen(cmd) do |com|
18 com.each_char do |c|
19 print c
20 output << c
21 $stdout.flush
22 end
23 end
24 form_growl_message output
25 end
26
27 def run_test_file(file)
28 run %Q(ruby -I"lib:test" -rubygems #{file})
29 end
30
31 def run_all_tests
32 run "rake test"
33 end
34
35 def related_test_files(path)
36 Dir['test/**/*.rb'].select { |file| file =~ /test_#{File.basename(path)}/ }
37 end
38
9aea956 @jnunemaker Setting watchr back up to run for individual files rather than all te…
jnunemaker authored
39 # watch('.*\.rb') { system('clear'); run_all_tests }
40 watch('test/helper\.rb') { system('clear'); run_all_tests }
41 watch('test/.*test_.*\.rb') { |m| system('clear'); run_test_file(m[0]) }
42 watch('lib/.*') { |m| related_test_files(m[0]).each { |file| run_test_file(file) } }
6f5dbda @jnunemaker Added watchr goodies.
jnunemaker authored
43
44 # Ctrl-\
45 Signal.trap('QUIT') do
46 puts " --- Running all tests ---\n\n"
47 run_all_tests
48 end
49
50 # Ctrl-C
51 Signal.trap('INT') { abort("\n") }
52
Something went wrong with that request. Please try again.