[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 4d1acb8 294/340: test: Rewrite buttercup-run tes
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 4d1acb8 294/340: test: Rewrite buttercup-run tests using spies |
Date: |
Thu, 16 Dec 2021 14:59:53 -0500 (EST) |
branch: elpa/buttercup
commit 4d1acb8bd9db023f78ac999660a854409851d149
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
test: Rewrite buttercup-run tests using spies
---
tests/test-buttercup.el | 41 ++++++++++++++++-------------------------
1 file changed, 16 insertions(+), 25 deletions(-)
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index da69317..02bc561 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -1323,41 +1323,32 @@ text properties using `ansi-color-apply'."
:to-throw)))))
(describe "The `buttercup-run' function"
- :var (parent-suite child-suite spec reporter)
+ :var (parent-suite child-suite spec)
(before-each
- (ignore reporter)
- (setf (symbol-function 'reporter) (lambda (event arg) (ignore event arg)))
(setq parent-suite (make-buttercup-suite :description "parent-suite")
child-suite (make-buttercup-suite :description "child-suite")
spec (make-buttercup-spec :description "spec"))
(buttercup-suite-add-child parent-suite child-suite)
(buttercup-suite-add-child child-suite spec)
- (spy-on 'reporter))
+ (spy-on 'reporter)
+ (spy-on 'buttercup--run-suite))
+ (it "should signal an error if no suites are defined"
+ (with-local-buttercup
+ (expect (buttercup-run) :to-throw 'error '("No suites defined"))))
(it "should raise an error if at least one spec failed"
(setf (buttercup-spec-status spec) 'failed)
- (cl-letf (((symbol-function 'buttercup--run-suite) #'ignore)
- (buttercup-reporter 'reporter))
- (let ((buttercup-suites (list parent-suite)))
- (expect (buttercup-run) :to-throw))))
+ (with-local-buttercup :suites (list parent-suite)
+ (expect (buttercup-run) :to-throw 'error '(""))))
(it "should call the reporter twice with events buttercup-started and -done"
- (cl-letf (((symbol-function 'buttercup--run-suite) #'ignore)
- (buttercup-reporter 'reporter))
- (let ((buttercup-suites (list parent-suite)))
- (expect (buttercup-run) :not :to-throw)
- (expect 'reporter :to-have-been-called-times 2)
- (expect 'reporter :to-have-been-called-with 'buttercup-started
buttercup-suites)
- (expect 'reporter :to-have-been-called-with 'buttercup-done
buttercup-suites)))
- )
+ (with-local-buttercup :suites (list parent-suite) :reporter 'reporter
+ (expect (buttercup-run) :not :to-throw)
+ (expect 'reporter :to-have-been-called-times 2)
+ (expect 'reporter :to-have-been-called-with 'buttercup-started
buttercup-suites)
+ (expect 'reporter :to-have-been-called-with 'buttercup-done
buttercup-suites)))
(it "should call `buttercup--run-suite' once per suite"
- (let ((buttercup-suites (list parent-suite)) runner)
- (ignore runner)
- (setf (symbol-function 'runner) (lambda (suite) (ignore suite)))
- (spy-on 'runner)
- (cl-letf (((symbol-function 'buttercup--run-suite) #'runner)
- (buttercup-reporter 'reporter)
- (buttercup-suites (make-list 5 parent-suite)))
- (expect (buttercup-run) :not :to-throw)
- (expect 'runner :to-have-been-called-times 5)))))
+ (with-local-buttercup :reporter 'reporter :suites (make-list 5
parent-suite)
+ (expect (buttercup-run) :not :to-throw)
+ (expect 'buttercup--run-suite :to-have-been-called-times 5))))
(describe "The `buttercup--print' function"
(before-each
- [nongnu] elpa/buttercup cf4eee8 274/340: test: Verify output in the "The batch reporter" suite, (continued)
- [nongnu] elpa/buttercup cf4eee8 274/340: test: Verify output in the "The batch reporter" suite, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4159111 275/340: test: Verify full line for reporter spec-done tests, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fbb790b 278/340: test: Add tests for buttercup-started and buttercup-reporter-batch-color, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d563e18 281/340: test: Add color tests for suite-done, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b910b71 285/340: Extract buttercup--indented-description from the batch reporters, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup e71a40f 287/340: Make sure carriage movement characters are not colorized, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a22fc29 288/340: Bump version: 1.21 → 1.22, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dde8651 290/340: Add new function buttercup--spec-mark-pending and use it, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c59110b 291/340: test: Extend with-local-buttercup with some key arguments, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d443ecb 293/340: Clarify patterns in bin/buttercup, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4d1acb8 294/340: test: Rewrite buttercup-run tests using spies,
ELPA Syncer <=
- [nongnu] elpa/buttercup 37223e4 296/340: actions: Run actions on push for all branches, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 50c7fc2 297/340: Switch to pcase in spec-done case of buttercup-reporter-batch, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dd32cc7 298/340: test: Fix "should color-print pending spec count in default color", ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0debeec 299/340: test: Use with-local-buttercup in more tests, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b3acf50 304/340: Lift spec-started handling into buttercup-reporter-batch, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 24a7bb9 306/340: Extract buttercup-reporter-batch--print-spec-done-line, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c9addd5 307/340: Lift spec-done handling into buttercup-reporter-batch, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d6de872 309/340: Improve buttercup-reporter-batch--print-failed-spec-report, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 392b99c 310/340: Extend batch reporters to optionally print sparse reports, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup f6ab784 315/340: test: Test on GNU Emacs 27.1, ELPA Syncer, 2021/12/16