File tree Expand file tree Collapse file tree 1 file changed +21
-15
lines changed Expand file tree Collapse file tree 1 file changed +21
-15
lines changed Original file line number Diff line number Diff line change 1919
2020; ;; Commentary:
2121
22- ; ; Non-interactive test suite setup for ERT Runner .
22+ ; ; Non-interactive test suite setup.
2323
2424; ;; Code:
2525
3232 ; ; Load the file under test
3333 (load (expand-file-name " clojure-mode" source-directory)))
3434
35- (defmacro def-refactor-test (name before after &rest body )
36- (declare (indent 3 ))
37- `(progn
38- (put ', name 'definition-name ', name )
39- (ert-deftest , name ()
40- (let ((clojure-thread-all-but-last nil )
41- (clojure-use-metadata-for-privacy nil ))
42- (with-temp-buffer
43- (insert , before )
44- (clojure-mode)
45- ,@body
46- (should (equal ,(concat " \n " after)
47- (concat " \n " (buffer-substring-no-properties
48- (point-min ) (point-max ))))))))))
35+ (defmacro with-clojure-buffer (text &rest body )
36+ " Create a temporary buffer, insert TEXT, switch to clojure-mode and evaluate BODY."
37+ `(with-temp-buffer
38+ (erase-buffer )
39+ (insert , text )
40+ (clojure-mode)
41+ ,@body ))
4942
43+ (defmacro when-refactoring-it (description before after &rest body )
44+ " Return a buttercup spec.
45+
46+ Insert BEFORE into a buffer, evaluate BODY and compare the resulting buffer to
47+ AFTER.
48+
49+ BODY should contain the refactoring that transforms BEFORE into AFTER.
50+
51+ DESCRIPTION is the description of the spec."
52+ `(it , description
53+ (with-clojure-buffer , before
54+ ,@body
55+ (expect (buffer-string ) :to-equal , after ))))
5056
5157; ;; test-helper.el ends here
You can’t perform that action at this time.
0 commit comments