Skip to content

Instantly share code, notes, and snippets.

@kossnocorp
Created July 20, 2012 10:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kossnocorp/3150108 to your computer and use it in GitHub Desktop.
Save kossnocorp/3150108 to your computer and use it in GitHub Desktop.
guard :rake, task: 'test', notification: false do
watch(/^(src|spec)\/(.+)\.coffee$/)
end
require 'rubygems'
require 'open3'
require 'talks'
task :test do
stdin, stdout, stderr = Open3.popen3 \
'./node_modules/mocha/bin/mocha ./spec/*_spec.coffee --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
end
message = "#{complete_count} tests complete"
message += ", #{pending_count} tests pending" if pending_count
else
message = 'Something wrong, check console output.'
end
Talks.say message, notify: true, detach: true
end
@gazay
Copy link

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