-
Notifications
You must be signed in to change notification settings - Fork 3
/
watchr.rb
37 lines (29 loc) · 787 Bytes
/
watchr.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
puts "\n### Watching specs and features ... ###\n"
#def cmd() 'bundle exec spec -O spec/spec.opts '; end
def cmd() 'rspec '; end
def run_all_specs
system(cmd + 'spec/')
end
def run_spec(spec)
puts "Running #{spec}"
puts(cmd + spec)
system(cmd + spec)
puts
end
def run_all_features
puts 'Running all features'
system 'rake cucumber'
end
watch('^spec/.*_spec\.rb') {|md| run_spec(md[0]) }
watch('spec/spec_helper.rb') {|md| run_all_specs }
watch('^lib/ruport/(.*)\.rb') {|md| run_spec("spec/lib/ruport/#{md[1]}_spec.rb")}
watch('^lib/(.*)\.rb') {|md| run_spec("spec/#{md[1]}_spec.rb")}
# Ctrl-\
Signal.trap('QUIT') do
puts "\n### Running all specs and features ###\n"
run_all_specs
run_all_features
puts
end
# Ctrl-C
Signal.trap('INT') { abort("\n") }