forked from mynyml/watchr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
specs.watchr
37 lines (31 loc) · 1.14 KB
/
specs.watchr
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
# Run me with:
# $ observr specs.observr
# --------------------------------------------------
# Rules
# --------------------------------------------------
watch( '^test.*/test_.*\.rb' ) { |m| ruby m[0] }
watch( '^lib/(.*)\.rb' ) { |m| ruby "test/test_#{m[1]}.rb" }
watch( '^lib/observr/(.*)\.rb' ) { |m| ruby "test/test_#{m[1]}.rb" }
watch( '^lib/observr/event_handlers/(.*)\.rb' ) { |m| ruby "test/event_handlers/test_#{m[1]}.rb" }
watch( '^test/test_helper\.rb' ) { ruby tests }
# --------------------------------------------------
# Signal Handling
# --------------------------------------------------
Signal.trap('QUIT') { ruby tests } # Ctrl-\
Signal.trap('INT' ) { abort("\n") } # Ctrl-C
# --------------------------------------------------
# Helpers
# --------------------------------------------------
def ruby(*paths)
run "ruby #{gem_opt} -I.:lib:test -e'%w( #{paths.flatten.join(' ')} ).each {|p| require p }'"
end
def tests
Dir['test/**/test_*.rb'] - ['test/test_helper.rb']
end
def run( cmd )
puts cmd
system cmd
end
def gem_opt
defined?(Gem) ? "-rubygems" : ""
end