Skip to content

Instantly share code, notes, and snippets.

@carvalhoviniciusluiz
Created September 6, 2016 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carvalhoviniciusluiz/6950abaebf9148b50ffa11b84eb3cd7b to your computer and use it in GitHub Desktop.
Save carvalhoviniciusluiz/6950abaebf9148b50ffa11b84eb3cd7b to your computer and use it in GitHub Desktop.
Autotest with PHPUnit for Laravel
# based on source
# https://gist.github.com/itscuriousdele/3179575
#
# prereqs:
# ruby
# gem install watchr
# gem install rb-inotify
#
# user:
# watchr autotest.test
watch('tests/.*Test\.php') { |m| code_changed(m[0]) }
def code_changed(file)
run "phpunit #{file}"
end
def clear
puts "\e[H\e[2J" #clear console
end
def run(cmd)
clear
notify `#{cmd}` rescue nil
end
def notify(message)
puts message #show console
message = message.split("\n").last(3);
title = message.find { |e| /FAILURES/ =~ e } ? "FAILURES" : "PASS"
image = (title == "FAILURES") ? "face-crying" : "face-laugh"
`notify-send "#{title}" "#{message[2]}" -i "#{image}"`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment