[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 0f3eb63 078/340: Show actual function arguments
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 0f3eb63 078/340: Show actual function arguments when a spy fails. |
Date: |
Thu, 16 Dec 2021 14:59:07 -0500 (EST) |
branch: elpa/buttercup
commit 0f3eb636c220ab4b822d309d7a0f6817e0fb9229
Author: Jorgen Schaefer <contact@jorgenschaefer.de>
Commit: Jorgen Schaefer <contact@jorgenschaefer.de>
Show actual function arguments when a spy fails.
It's not very helpful to be told that a spy was not called with the
expected arguments without being told what it actually was being
called with.
Fixes #19
---
buttercup.el | 18 +++++++++++++++---
tests/test-buttercup.el | 10 ++++++----
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index 9a67d2d..f9f0a44 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -565,9 +565,21 @@ KEYWORD can have one of the following values:
(buttercup-define-matcher :to-have-been-called-with (spy &rest args)
(let* ((calls (mapcar 'spy-context-args (spy-calls-all spy))))
- (if (member args calls)
- t
- nil)))
+ (cond
+ ((not calls)
+ (cons nil
+ (format "Expected `%s' to have been called with %s, but it was not
called at all" spy args)))
+ ((not (member args calls))
+ (cons nil
+ (format "Expected `%s' to have been called with %s, but it was
called with %s"
+ spy
+ args
+ (mapconcat (lambda (args)
+ (format "%S" args))
+ calls
+ ", "))))
+ (t
+ t))))
(defun spy-calls-any (spy)
"Return t iff SPY has been called at all, nil otherwise."
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 8cc48d8..5df1952 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -499,15 +499,17 @@
(it "returns false if the spy was not called at all"
(expect (buttercup--apply-matcher
:to-have-been-called-with '(test-function 1 2 3))
- :to-be
- nil))
+ :to-equal
+ (cons nil
+ "Expected `test-function' to have been called with (1 2
3), but it was not called at all")))
(it "returns false if the spy was called with different arguments"
(test-function 3 2 1)
(expect (buttercup--apply-matcher
:to-have-been-called-with '(test-function 1 2 3))
- :to-be
- nil))
+ :to-equal
+ (cons nil
+ "Expected `test-function' to have been called with (1 2
3), but it was called with (3 2 1)")))
(it "returns true if the spy was called with those arguments"
(test-function 1 2 3)
- [nongnu] elpa/buttercup 444716b 079/340: Handle windows better in interactive runs., (continued)
- [nongnu] elpa/buttercup 444716b 079/340: Handle windows better in interactive runs., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 512b82b 077/340: Rework documentation to make the readme more concise., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 238bfa8 082/340: Support --pattern command line argument, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5cbd468 084/340: Bump version: 1.2 → 1.3, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ba8cd05 106/340: Merge pull request #59 from immerrr/add-other-emacs-params, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 07c525e 116/340: Merge pull request #68 from ebpa/report-load-errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 11f072f 123/340: Merge pull request #81 from DamienCassou/fix-to-have-same-items-as, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 562cdb0 058/340: The buttercup-suite-full-name function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d264da3 075/340: Merge pull request #17 from Fuco1/master, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8c486e6 067/340: Move print settings to the batch reporter where they belong., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0f3eb63 078/340: Show actual function arguments when a spy fails.,
ELPA Syncer <=
- [nongnu] elpa/buttercup 357e73b 085/340: Remove debug message, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 68692d9 113/340: Update Travis configuration instructions, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 54696b0 124/340: Merge pull request #78 from Fuco1/feature/buttercup-minor-mode, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 77f0c74 122/340: Fix :to-have-same-items-as (fix #80), ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 20ec520 145/340: Rename functions and arguments for closure manipulation, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 5d1f338 146/340: Move let-binding outside loop for efficiency, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7fa79c4 048/340: Expand and improve the package commentary., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 4f68f0b 059/340: The buttercup-spec-full-name function., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup ef7b730 063/340: Various improvements of the batch reporter., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a55a638 064/340: More and better tests for the batch reporter., ELPA Syncer, 2021/12/16