Skip to content
Newer
Older
100644 34 lines (29 sloc) 697 Bytes
01afd6f @jnunemaker Added watchr file.
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
579b5fe @jnunemaker removed growl from watchr.
authored
11 output
01afd6f @jnunemaker Added watchr file.
authored
12 end
13
14 def run_spec(path)
15 path.gsub!('lib/', 'spec/')
16 path.gsub!('_spec', '')
17 file_name = File.basename(path, '.rb')
18 path.gsub!(file_name, file_name + "_spec")
19 run %Q(bundle exec rspec #{path})
20 end
21
22 watch('spec/helper\.rb') { system('clear'); run('rake') }
23 watch('lib/.*\.rb') { |m| system('clear'); run_spec(m[0]) }
24 watch('spec/.*_spec\.rb') { |m| system('clear'); run_spec(m[0]) }
25
26 # Ctrl-\
27 Signal.trap('QUIT') do
28 puts " --- Running all tests ---\n\n"
29 run('rake')
30 end
31
32 # Ctrl-C
33 Signal.trap('INT') { abort("\n") }
Something went wrong with that request. Please try again.