[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup debe7cc 204/340: Merge pull request #144 from ke
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup debe7cc 204/340: Merge pull request #144 from kevinjfoley/support-var-star |
Date: |
Thu, 16 Dec 2021 14:59:35 -0500 (EST) |
branch: elpa/buttercup
commit debe7ccac6b7ad4ad99060a7e685bd69fdde8e0a
Merge: 810fa6f 2bc55fe
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #144 from kevinjfoley/support-var-star
Add support for :var*
---
.travis.yml | 1 +
buttercup.el | 13 +++++++++----
docs/writing-tests.md | 24 ++++++++++++++++++++++++
tests/test-buttercup.el | 7 ++++++-
4 files changed, 40 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index da3de57..8d00c58 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,6 +7,7 @@ env:
- EVM_EMACS=emacs-25.1-travis
- EVM_EMACS=emacs-25.2-travis
- EVM_EMACS=emacs-26.1-travis
+ - EVM_EMACS=emacs-26.2-travis
before_install:
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw >
travis.sh && source ./travis.sh
- evm install "$EVM_EMACS" --use --skip
diff --git a/buttercup.el b/buttercup.el
index 49f5669..dbeb966 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -805,10 +805,15 @@ form.")
DESCRIPTION is a string. BODY is a sequence of instructions,
mainly calls to `describe', `it' and `before-each'."
(declare (indent 1) (debug (&define sexp def-body)))
- (let ((new-body (if (eq (elt body 0) :var)
- `((let ,(elt body 1)
- ,@(cddr body)))
- body)))
+ (let ((new-body
+ (cond
+ ((eq (elt body 0) :var)
+ `((let ,(elt body 1)
+ ,@(cddr body))))
+ ((eq (elt body 0) :var*)
+ `((let* ,(elt body 1)
+ ,@(cddr body))))
+ (t body))))
`(buttercup-describe ,description (lambda () ,@new-body))))
(defun buttercup-describe (description body-function)
diff --git a/docs/writing-tests.md b/docs/writing-tests.md
index c478111..3383467 100644
--- a/docs/writing-tests.md
+++ b/docs/writing-tests.md
@@ -202,6 +202,30 @@ as full sentences in traditional
(expect t :to-equal t))))
```
+### Declaring Variables
+
+The `describe` macro supports the optional `:var` and `:var*` args.
+These bind variables for the suite by passing them as a varlist to the
+`let` and `let*` form respectively.
+
+```Emacs-Lisp
+(describe "A spec using :VAR"
+ :var ((foo 1))
+ (it "has access to the variables bound in :VAR"
+ (expect foo :to-be 1)))
+
+(describe "A spec using :VAR*"
+ :var* ((foo 1)
+ (bar (1+ foo)))
+ (it "has access to the variables bound in :VAR* which can refer \
+to symbols already bound"
+ (expect bar :to-be 2)))
+```
+
+It's important to note that `lexical-binding` must be `non-nil` for
+`:var` and `:var*` to work properly. Within a test file this is
+usually set using a local file variable.
+
### Setup and Teardown
To help a test suite DRY up any duplicated setup and teardown code,
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 5a660e6..b78c104 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -379,7 +379,12 @@
(expect (macroexpand '(describe "description" :var (foo bar) (+ foo bar)))
:to-equal
'(buttercup-describe "description"
- (lambda () (let (foo bar) (+ foo bar)))))))
+ (lambda () (let (foo bar) (+ foo bar))))))
+ (it "should support the :var* argument"
+ (expect (macroexpand '(describe "description" :var* (foo bar) (+ foo bar)))
+ :to-equal
+ '(buttercup-describe "description"
+ (lambda () (let* (foo bar) (+ foo bar)))))))
(describe "The `buttercup-describe' function"
(it "should run the enclosing body"
- [nongnu] elpa/buttercup 2aa840c 088/340: Merge pull request #40 from lunaryorn/assume-form, (continued)
- [nongnu] elpa/buttercup 2aa840c 088/340: Merge pull request #40 from lunaryorn/assume-form, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6c11d8e 097/340: Debian and Ubuntu installation instructions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ae606fc 153/340: Set failure description to empty string for pending specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 34e12fd 154/340: Get rid of 60 compile-time warnings out of 97, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 897d0e7 155/340: Remove some warnings on test-buttercup.el, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 25046d3 160/340: Rewrite buttercup--update-with-funcall with suite-or-spec functions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 85aebcd 168/340: Fix issue #121, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4089d5f 194/340: Bump version: 1.14 → 1.15, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 1850253 195/340: Remove duplicate buttercup-color declaration, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 2bc55fe 201/340: Add emacs-26.2 to CI config, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup debe7cc 204/340: Merge pull request #144 from kevinjfoley/support-var-star,
ELPA Syncer <=
- [nongnu] elpa/buttercup c2d75e9 209/340: Bump version: 1.17 → 1.18, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup bb3fba3 227/340: Properly handle return values and thrown signals in spies, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a970d10 228/340: Implement spy-calls-count-returned and spy-calls-count-errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8d91893 232/340: Optimize spy-calls-count-errors and spy-calls-count-returned, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 83141f7 243/340: Raise an error if spy-on is used in the wrong context, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 16e3530 090/340: Also update Makefile to the new docs names, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 794afbf 114/340: Merge pull request #65 from DamienCassou/patch-1, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d5c9a19 120/340: Make --with-cleanup public so spies can be used without specs, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 79286cf 055/340: Test for the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 87e0c0d 073/340: Bump version: 1.0 → 1.1, ELPA Syncer, 2021/12/16