Skip to content

Instantly share code, notes, and snippets.

@sbastn
Created February 14, 2012 08:22
Show Gist options
  • Save sbastn/1824791 to your computer and use it in GitHub Desktop.
Save sbastn/1824791 to your computer and use it in GitHub Desktop.
My coffeescript TDD super fast feedback loop
Get the parts
* jasmine-node (https://github.com/mhevery/jasmine-node)
* watchr (https://github.com/mynyml/watchr)
* growlnotify (you can brew this)
* And of course coffeescript :)
You can see the demo here: http://holatdd.com/videos/kata-lonja (just advance the 5 first mins or so)
Create a project like this
├── spec
│   └── coffeescripts
│   └── simple_spec.coffee
└── watch.rb
2 directories, 2 files
The watch.rb file is described below...
system('clear')
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "the doom guy says"
image = message.include?('0 failures') ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
end
def run(cmd)
puts(cmd)
`#{cmd}`
end
def run_specs
result = run 'jasmine-node --coffee spec'
result.gsub!('[32m', '') # ... Successful tests
result.gsub!('[31m', '') # FFF Failed tests
result.gsub!('[0m', '') # Closing colors from the terminal
puts result
growl result.split('\n').last rescue nil
end
watch('spec/coffeescripts/.*'){ |m| run_specs }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment