Skip to content

Instantly share code, notes, and snippets.

@elia
Created September 21, 2009 12:14
Show Gist options
  • Save elia/190209 to your computer and use it in GitHub Desktop.
Save elia/190209 to your computer and use it in GitHub Desktop.
# this works only on macs...
Autotest.add_hook :ran_command do |autotest|
results = [autotest.results].flatten.join("\n")
examples = results.scan(/(\d+) examples?/).flatten.first.to_i || 0
failures = results.scan(/(\d+) failures?/).flatten.first.to_i || 0
pending = results.scan(/(\d+) pending/).flatten.first.to_i || 0
errors = results.scan(/(\d+) errors?/).flatten.first.to_i || 0
if [examples, failures, pending, errors].any?{|v| v > 0}
passed = examples - failures - pending - errors
if errors > 0 or failures > 0
`say failed #{failures} of #{examples}`
elsif pending > 0
`say pending #{pending} of #{examples}`
else
`say passed #{passed} of #{examples}`
end
puts Time.now.strftime("\e[1m%H:%M:%S\e[0m")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment