alexgb/guard-konacha — pull request #21 by CyborgMaster (2013-09-07 06:28:04+00:00)
Title: Dont run nonexistant tests

If your guardfile has watchers that resolve to pathnames that don't exist, guard-konacha crashes instead of skipping those files.

For example, I was using the following watchers in my rails project to watch both the tests and the files being tested:

watch(%r{^app/assets/javascripts/(.*)(\.js(\.coffee)?)$}) { |m| "#{m[1]}_test#{m[2]}" }
watch(%r{^test/javascripts/.+_test(\.js|\.js\.coffee)$})

The watcher for the tests themselves (2nd line) worked great, but the one that watched the javascript files and then found their corresponding test files (1st line) would crash if the test file didn't exists (I was working on foo.js, but there was no foo_test.js)

I fixed it by having the runner check to see if a file exists before it tries to run it.

PS. This is my first pull request on GitHub, so if I haven't done something correctly, please let me know and I will be happy to fix it.