Created
July 26, 2012 00:37
-
-
Save deletosh/3179575 to your computer and use it in GitHub Desktop.
Autotest PHPUnit in Laravel
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
# PHPUnit: http://bit.ly/NYYCWs | |
# Ruby: http://rubyinstaller.org/ (Mac) *OR* http://rubyinstaller.org/ (Win) | |
# watchr: gem install watchr | |
# Growl: http://growl.info/ | http://bit.ly/NYYCWs (Mac) *OR* http://bit.ly/NYYrdF (Win) | |
# save in same level as 'artisan', then run watchr_imagesr autounit.rb | |
# src: http://bit.ly/NYZMRT | |
#watch just the test files (optionally superceeded by the next line) | |
#watch('(.*.test).php$') { |m| code_changed(m[0]) } | |
watch('(.+)\.php$') { |m| code_changed(m[0]) } | |
def code_changed(file) | |
run "php artisan test" | |
end | |
def run(cmd) | |
result = `#{cmd}` | |
growl result rescue nil | |
end | |
def growl(message) | |
puts(message) | |
message = message.split("\n").last(3); | |
growlnotify = `which growlnotify`.chomp | |
title = message.find { |e| /FAILURES/ =~ e } ? "FAILURES" : "PASS" | |
if title == "FAILURES" | |
# this is the path to the images | |
# that is shown in growl | |
image = "~/.watchr_images/failed.jpg" | |
info = /\x1b\[37;41m\x1b\[2K(.*)/.match(message[1])[1] | |
else | |
image = "~/.watchr_images/passed.png" | |
info = /\x1b\[30;42m\x1b\[2K(.*)/.match(message[1])[1] | |
end | |
options = "-w -n Watchr --image '#{File.expand_path(image)}' --html '#{title}' -m '#{info}'" | |
system %(#{growlnotify} #{options} &) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment