1
0
Fork 0

Add auto-insert template for bats-mode

This commit is contained in:
Tom Willemse 2020-01-07 17:17:35 -08:00
parent 487f25a7a6
commit 5ea266270d
3 changed files with 22 additions and 1 deletions

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; Keywords: local
;; Version: 2019.1117.104022 ;; Version: 2020.0107.171424
;; Package-Requires: (bats-mode oni-sh) ;; Package-Requires: (bats-mode oni-sh)
;; This program is free software; you can redistribute it and/or modify ;; This program is free software; you can redistribute it and/or modify
@ -29,6 +29,11 @@
;;; Code: ;;; Code:
(require 'autoinsert)
;;;###autoload
(add-to-list 'auto-insert-alist '(bats-mode nil "#!/usr/bin/env bats\n\n"))
;;;###autoload(with-eval-after-load 'bats-mode (require 'oni-bats)) ;;;###autoload(with-eval-after-load 'bats-mode (require 'oni-bats))
(provide 'oni-bats) (provide 'oni-bats)

9
test/integration/oni-bats.bats Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bats
@test "Loading a bats file loads oni-bats" {
run emacs -batch -l package -f package-initialize \
-visit test.bats \
-eval "(prin1 (featurep 'oni-bats))"
[[ "$output" == *"t" ]]
}

7
test/oni-bats-test.el Normal file
View file

@ -0,0 +1,7 @@
(ert-deftest oni-bats-test-auto-insert ()
"Test that auto-insert inserts the proper interpreter."
(with-temp-buffer
(bats-mode)
(let ((auto-insert-query nil))
(auto-insert))
(should (string= "#!/usr/bin/env bats\n\n" (buffer-string)))))