Skip to content

Instantly share code, notes, and snippets.

@mgaare
Created June 28, 2013 18:20
Show Gist options
  • Save mgaare/5886837 to your computer and use it in GitHub Desktop.
Save mgaare/5886837 to your computer and use it in GitHub Desktop.
Settings to allow test <-> implementation file jumping to work when using speclj rather than clojure.test
;; test mode setup for speclj
(require 'clojure-test-mode)
;; Test navigation:
(defun clojure-in-tests-p ()
(or (string-match-p "spec\." (clojure-find-ns))
(string-match-p "/spec" (buffer-file-name))))
(defun clojure-test-for (namespace)
"Returns the path of the test file for the given namespace."
(let* ((namespace (clojure-underscores-for-hyphens namespace))
(segments (split-string namespace "\\.")))
(format "%sspec/%s_spec.clj"
(file-name-as-directory
(locate-dominating-file buffer-file-name "src/"))
(mapconcat 'identity segments "/"))))
(defvar clojure-test-for-fn 'clojure-test-for)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment