Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Created January 9, 2012 11:50
Show Gist options
  • Save lazywithclass/1582626 to your computer and use it in GitHub Desktop.
Save lazywithclass/1582626 to your computer and use it in GitHub Desktop.
TDD functions for emacs
(global-set-key (kbd "C-c C-r") 'run-mocha)
(defun run-mocha()
"Runs all the tests in the current buffer"
(interactive)
(let* (command result exit-value)
(setq command (concat "mocha -r should " (buffer-name)))
(setq exit-value (shell-command command))
(color-modeline exit-value)))
(defun color-modeline(exit-value)
"Colors the modeline, green success red failure"
(interactive)
(let (test-result-color)
(if (= exit-value 0)
(setq test-result-color "Green")
(setq test-result-color "Red"))
(set-face-background 'modeline test-result-color)
(run-at-time "1 sec" nil 'no-color-modeline)))
(defun no-color-modeline()
"No color for the modeline"
(interactive)
(set-face-background 'modeline nil))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment