emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/buttercup 764d6aa 020/340: Tests for the it macro and butt


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 764d6aa 020/340: Tests for the it macro and buttercup-it function.
Date: Thu, 16 Dec 2021 14:58:57 -0500 (EST)

branch: elpa/buttercup
commit 764d6aab96ea3a267d34e36360a4827db157225a
Author: Jorgen Schaefer <contact@jorgenschaefer.de>
Commit: Jorgen Schaefer <contact@jorgenschaefer.de>

    Tests for the it macro and buttercup-it function.
---
 buttercup-test.el | 25 +++++++++++++++++++++++++
 buttercup.el      |  6 +++---
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/buttercup-test.el b/buttercup-test.el
index d6e43b2..933c770 100644
--- a/buttercup-test.el
+++ b/buttercup-test.el
@@ -186,3 +186,28 @@
         (expect (buttercup-suite-description child-suite)
                 :to-equal
                 desc2)))))
+
+(describe "The `it' macro"
+  (it "should expand to a call to the `buttercup-it' function"
+    (expect (macroexpand '(it "description" body))
+            :to-equal
+            '(buttercup-it "description" (lambda () body)))))
+
+(describe "The `buttercup-it' function"
+  (it "should fail if not called from within a describe form"
+    (expect (lambda ()
+              (let ((buttercup--current-suite nil))
+                (buttercup-it "" (lambda ()))))
+            :to-throw))
+
+  (it "should add a spec to the current suite"
+    (let ((buttercup--current-suite (make-buttercup-suite)))
+      (buttercup-it "the test spec"
+                    (lambda () 23))
+      (let ((spec (car (buttercup-suite-children buttercup--current-suite))))
+        (expect (buttercup-spec-description spec)
+                :to-equal
+                "the test spec")
+        (expect (funcall (buttercup-spec-function spec))
+                :to-equal
+                23)))))
diff --git a/buttercup.el b/buttercup.el
index ec852e6..6b73a3d 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -276,11 +276,11 @@ form.")
 (defmacro it (description &rest body)
   "Define a spec."
   (declare (indent 1))
-  `(buttercup--it-internal ,description (lambda () ,@body)))
+  `(buttercup-it ,description (lambda () ,@body)))
 
-(defun buttercup--it-internal (description body-function)
+(defun buttercup-it (description body-function)
   "Function to handle an `it' form."
-  (when (not description)
+  (when (not buttercup--current-suite)
     (error "`it' has to be called from within a `describe' form."))
   (buttercup-suite-add-child buttercup--current-suite
                              (make-buttercup-spec



reply via email to

[Prev in Thread] Current Thread [Next in Thread]