Created
August 29, 2011 20:16
-
-
Save xnzac/1179278 to your computer and use it in GitHub Desktop.
Guard file for running test unit / spec files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More info at https://github.com/guard/guard#readme | |
# Instructions: | |
# 1) gem install guard guard-shell | |
# 2) run guard in root | |
# run test with 'redgreen' gem(for colour) if available otherwise with plain ruby | |
guard "shell" do | |
watch(%r{^(.+)/.+\.rb$}) do |m| | |
if File.exists?("#{m[1]}/#{m[1]}_test.rb") | |
cmd = `which rg`.empty? ? "ruby" : "rg" | |
puts `cd #{m[1]}; #{cmd} #{m[1]}_test.rb` | |
else | |
puts `cd #{m[1]}; rspec #{m[1]}_spec.rb --color` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment