Created
February 14, 2012 08:22
-
-
Save sbastn/1824791 to your computer and use it in GitHub Desktop.
My coffeescript TDD super fast feedback loop
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
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... |
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
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