alexgb / guard-konacha

Automatically run konacha tests through Guard
MIT License
31 stars 17 forks source link

Dont run nonexistant tests #21

Closed CyborgMaster closed 10 years ago

CyborgMaster commented 10 years ago

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.

alexgb commented 10 years ago

Thanks for the contribution. Can you address the issues above?

CyborgMaster commented 10 years ago

Sure. You make a very good point about Tell don't ask. I'll make those changes and update the pull request later today. Thank you for reviewing my pull with a discerning eye.

CyborgMaster commented 10 years ago

I believe I have addressed your concerns. How does it look now?