aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2020-01-07 17:17:35 -0800
committerGravatar Tom Willemse2020-01-07 21:33:42 -0800
commit5ea266270db1c69b847d7d6b115b2817e5ad235b (patch)
tree68e9bc10cf3d64ea3fc9af5300c955e73838cdf5
parent487f25a7a6870ca78d7daeeccb7218ed4681a429 (diff)
downloademacs-config-5ea266270db1c69b847d7d6b115b2817e5ad235b.tar.gz
emacs-config-5ea266270db1c69b847d7d6b115b2817e5ad235b.zip
Add auto-insert template for bats-mode
-rw-r--r--oni-bats.el7
-rwxr-xr-xtest/integration/oni-bats.bats9
-rw-r--r--test/oni-bats-test.el7
3 files changed, 22 insertions, 1 deletions
diff --git a/oni-bats.el b/oni-bats.el
index ea05539..d969f28 100644
--- a/oni-bats.el
+++ b/oni-bats.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2019.1117.104022
+;; Version: 2020.0107.171424
;; Package-Requires: (bats-mode oni-sh)
;; This program is free software; you can redistribute it and/or modify
@@ -29,6 +29,11 @@
;;; 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))
(provide 'oni-bats)
diff --git a/test/integration/oni-bats.bats b/test/integration/oni-bats.bats
new file mode 100755
index 0000000..fa5a513
--- /dev/null
+++ b/test/integration/oni-bats.bats
@@ -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" ]]
+}
diff --git a/test/oni-bats-test.el b/test/oni-bats-test.el
new file mode 100644
index 0000000..7414dc4
--- /dev/null
+++ b/test/oni-bats-test.el
@@ -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)))))