forked from zires/spready
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautotest.rb
More file actions
48 lines (43 loc) · 1.19 KB
/
autotest.rb
File metadata and controls
48 lines (43 loc) · 1.19 KB
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
38
39
40
41
42
43
44
45
46
47
48
# Clear console
system 'clear'
# --------------------------------------------------
# Rules
# --------------------------------------------------
watch('test/test_helper\.rb') { run_all_tests }
watch('test/.*/.*_test\.rb') { |m| run_test_file(m[0]) }
# Run related test file
# watch('app/.*/.*\.rb') { |m| related_test_files(m[0]).map {|tf| run_test_file(tf) } }
# watch('features/.*/.*\.feature') { run_all_features }
# --------------------------------------------------
# Signal Handling
# --------------------------------------------------
# Ctrl-\
Signal.trap('QUIT') { run_all_tests }
# Ctrl-C
# Signal.trap('INT' ) { abort("\n") }
# Before abort, we need run all tests again
Signal.trap('INT' ) do
if @interrupted
abort("\n")
else
puts "Interrupt a second time to quit"
@interrupted = true
Kernel.sleep 1.5
run_all_tests
end
end
# --------------------------------------------------
# Helpers
# --------------------------------------------------
def run(cmd)
puts cmd
system cmd
end
def run_all_tests
system 'clear'
run "rake test"
end
def run_test_file(file)
system 'clear'
run(%Q(ruby -I"lib:test" -rubygems #{file}))
end