Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 46 lines (39 sloc) 0.998 kb
01afd6f John Nunemaker Added watchr file.
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 msg = str.split("\n").last
7 if msg =~ /(\d)\sfailure/
8 img = $1.to_i > 0 ? 'fail' : 'pass'
9 end
10 growl 'Results', msg, img
11 end
12
13 def run(cmd)
14 puts cmd
15 output = ""
16 IO.popen(cmd) do |com|
17 com.each_char do |c|
18 print c
19 output << c
20 $stdout.flush
21 end
22 end
23 form_growl_message output
24 end
25
26 def run_spec(path)
27 path.gsub!('lib/', 'spec/')
28 path.gsub!('_spec', '')
29 file_name = File.basename(path, '.rb')
30 path.gsub!(file_name, file_name + "_spec")
31 run %Q(bundle exec rspec #{path})
32 end
33
34 watch('spec/helper\.rb') { system('clear'); run('rake') }
35 watch('lib/.*\.rb') { |m| system('clear'); run_spec(m[0]) }
36 watch('spec/.*_spec\.rb') { |m| system('clear'); run_spec(m[0]) }
37
38 # Ctrl-\
39 Signal.trap('QUIT') do
40 puts " --- Running all tests ---\n\n"
41 run('rake')
42 end
43
44 # Ctrl-C
45 Signal.trap('INT') { abort("\n") }
Something went wrong with that request. Please try again.