Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added tests.watchr file.

  • Loading branch information...
commit 7596caf84ad8521a9a8245404292e48a15b9e396 1 parent 339c6bf
@lantins authored
Showing with 41 additions and 0 deletions.
  1. +41 −0 tests.watchr
View
41 tests.watchr
@@ -0,0 +1,41 @@
+# Run me with:
+# $ watchr tests.watchr
+
+# --------------------------------------------------
+# Rules
+# --------------------------------------------------
+
+# if we edit main lib files
+watch( '^lib/(.*).rb' ) { ruby all_tests }
+# if we edit Gemfile or Gemspec.
+watch( '^(Gemfile*|resque-lock-timeout.gemspec)' ) { ruby all_tests }
+# if we edit any test related files.
+watch( '^test/.*' ) { ruby all_tests }
+
+#### INTERGRATION
+
+# --------------------------------------------------
+# Signal Handling
+# --------------------------------------------------
+Signal.trap('QUIT') { ruby all_tests } # Ctrl-\
+Signal.trap('INT' ) { abort("\n") } # Ctrl-C
+
+# --------------------------------------------------
+# Helpers
+# --------------------------------------------------
+def ruby(*paths)
+ run "bundle exec ruby #{gem_opt} -I.:lib:test -e'%w( #{paths.flatten.join(' ')} ).each { |p| require p }'"
+end
+
+def all_tests
+ Dir['test/**/*_test.rb']
+end
+
+def run(cmd)
+ puts cmd
+ system cmd
+end
+
+def gem_opt
+ defined?(Gem) ? '-rubygems' : ''
+end
Please sign in to comment.
Something went wrong with that request. Please try again.