Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
guard :rake, task: 'test', notification: false do
require 'rubygems'
require 'open3'
require 'talks'
task :test do
stdin, stdout, stderr = Open3.popen3 \
'./node_modules/mocha/bin/mocha ./spec/* --compilers coffee:coffee-script -R spec -c'
puts stdout_array = stdout.readlines
puts stderr_array = stderr.readlines
stdout_strings = stdout_array.to_s
stderr_strings = stderr_array.to_s
if stderr_strings and
error_match = stderr_strings.match(/(\d+) of (\d+) tests failed/)
failed_count, total_count = error_match.captures
message = "#{failed_count} of #{total_count} tests failed"
elsif stdout_strings_match = stdout_strings.match(/(\d+) tests complete/)
complete_count, = stdout_strings_match.captures
if pending_matches = stdout_strings.match(/(\d+) tests pending/)
pending_count, = pending_matches.captures
message = "#{complete_count} tests complete"
message += ", #{pending_count} tests pending" if pending_count
message = 'Something wrong, check console output.'
Talks.say message, notify: true, detach: true

gazay commented Jul 20, 2012

Nice autotesting tool on mocha, rake, guard and talks gem for coffeescript files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment