branch: elpa/buttercup commit e26ea5408414268253cfb3d869ab3ca8b2864436 Author: Ola Nilsson <ola.nils...@gmail.com> Commit: Jorgen Schäfer <jorgen.schae...@gmail.com>
Let spy-on :and-return-value work with lists and symbols (close #104) --- buttercup.el | 2 +- tests/test-buttercup.el | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/buttercup.el b/buttercup.el index 9d72eaa..570c63a 100644 --- a/buttercup.el +++ b/buttercup.el @@ -574,7 +574,7 @@ responsibility to ensure ARG is a command." (:and-return-value `(lambda (&rest args) ,orig-intform - ,arg)) + ',arg)) (:and-call-fake (let ((replacement-intform (interactive-form arg))) (when (and replacement-intform diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el index 805ea8b..c120574 100644 --- a/tests/test-buttercup.el +++ b/tests/test-buttercup.el @@ -688,7 +688,47 @@ (it "returns the specified value" (expect (test-function 2 3) :to-equal - 23))) + 23)) + + (it "works with strings" + (spy-on 'test-function :and-return-value "return value") + (expect (test-function 2 3) + :to-equal + "return value")) + + (it "works with vectors" + (spy-on 'test-function :and-return-value [1 2 3 4]) + (expect (test-function 2 3) + :to-equal + [1 2 3 4])) + + (it "works with symbols" + (spy-on 'test-function :and-return-value 'symbol) + (expect (test-function 2 3) + :to-equal + 'symbol)) + + (it "works with conses" + (spy-on 'test-function :and-return-value '(1 . 2)) + (expect (test-function 2 3) + :to-equal + (cons 1 2))) + + (it "works with lists" + (spy-on 'test-function :and-return-value '(1 2 3)) + (expect (test-function 2 3) + :to-equal + '(1 2 3))) + + (it "works with alists" + (spy-on 'test-function :and-return-value '((first . 1) + (second . 2) + (third . 3))) + (expect (test-function 2 3) + :to-equal + '((first . 1) + (second . 2) + (third . 3))))) (describe ":and-call-fake keyword functionality" (before-each