Skip to content
Newer
Older
100644 52 lines (42 sloc) 1.12 KB
f2ebe80 @jnunemaker Moved serialization, associations, dirty tracking and callbacks to pl…
jnunemaker 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 results = str.split("\n").last
7 if results =~ /[1-9]\s(failure|error)s?/
8 growl "Test Results", "#{results}", "fail"
9 elsif results != ""
10 growl "Test Results", "#{results}", "pass"
11 end
12 end
13
316fbc6 @jnunemaker Added a watchr (gem install watchr) to make continuous testing easier.
jnunemaker authored
14 def run(cmd)
15 puts(cmd)
f2ebe80 @jnunemaker Moved serialization, associations, dirty tracking and callbacks to pl…
jnunemaker authored
16 output = ""
17 IO.popen(cmd) do |com|
18 com.each_char do |c|
19 print c
20 output << c
21 $stdout.flush
22 end
23 end
24 form_growl_message output
316fbc6 @jnunemaker Added a watchr (gem install watchr) to make continuous testing easier.
jnunemaker authored
25 end
26
27 def run_test_file(file)
25b481d @jnunemaker Fixed watch spec file to work autorequire lib and rubygems.
jnunemaker authored
28 run %Q(ruby -I"lib:test" -rubygems #{file})
316fbc6 @jnunemaker Added a watchr (gem install watchr) to make continuous testing easier.
jnunemaker authored
29 end
30
31 def run_all_tests
32 run "rake test"
33 end
34
35 def related_test_files(path)
32c454d @jnunemaker Models with _type key are no properly scoped when performing find and…
jnunemaker authored
36 Dir['test/**/*.rb'].select { |file| file =~ /test_#{File.basename(path)}/ }
316fbc6 @jnunemaker Added a watchr (gem install watchr) to make continuous testing easier.
jnunemaker authored
37 end
38
9ab45d9 @jnunemaker Removed focused watchr stuff. Back to vanilla.
jnunemaker authored
39 watch('test/test_helper\.rb') { system('clear'); run_all_tests }
40 watch('test/.*/test_.*\.rb') { |m| system('clear'); run_test_file(m[0]) }
1a15c24 @jnunemaker Minor: make watchr clear before running tests so it is easy to read
jnunemaker authored
41 watch('lib/.*') { |m| system('clear'); related_test_files(m[0]).each { |file| run_test_file(file) } }
316fbc6 @jnunemaker Added a watchr (gem install watchr) to make continuous testing easier.
jnunemaker authored
42
43 # Ctrl-\
44 Signal.trap('QUIT') do
45 puts " --- Running all tests ---\n\n"
46 run_all_tests
47 end
48
49 # Ctrl-C
50 Signal.trap('INT') { abort("\n") }
51
Something went wrong with that request. Please try again.