Skip to content

Instantly share code, notes, and snippets.

@xnzac
Created August 29, 2011 20:16
Show Gist options
  • Save xnzac/1179278 to your computer and use it in GitHub Desktop.
Save xnzac/1179278 to your computer and use it in GitHub Desktop.
Guard file for running test unit / spec files
# 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