Created
September 6, 2016 12:28
-
-
Save carvalhoviniciusluiz/6950abaebf9148b50ffa11b84eb3cd7b to your computer and use it in GitHub Desktop.
Autotest with PHPUnit for 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
# 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