[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 60028db 236/340: docs: Clarify the spy lifespan
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 60028db 236/340: docs: Clarify the spy lifespan in writing-tests.md |
Date: |
Thu, 16 Dec 2021 14:59:41 -0500 (EST) |
branch: elpa/buttercup
commit 60028dbc34b5ac67b8bdb7c46c7b1d8f6f69de0a
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
docs: Clarify the spy lifespan in writing-tests.md
---
docs/writing-tests.md | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/docs/writing-tests.md b/docs/writing-tests.md
index 9d6cc54..43a4da5 100644
--- a/docs/writing-tests.md
+++ b/docs/writing-tests.md
@@ -361,9 +361,11 @@ pending in results.
Buttercup has test double functions called spies. While other
frameworks call these mocks and similar, we call them spies, because
their main job is to spy in on function calls. Also, Jasmine calls
-them spies, and so do we. A spy can stub any function and tracks calls
+them spies, and so do we. A spy can stub any function - whether it
+already exists or not - and tracks calls
to it and all arguments. A spy only exists in the `describe` or `it`
-block it is defined in, and will be removed after each spec. There are
+block it is defined in, and will be activated before and deactivated
+and reset after each spec. There are
special matchers for interacting with spies. The
`:to-have-been-called` matcher will return true if the spy was called
at all. The `:to-have-been-called-with` matcher will return true if
@@ -383,7 +385,21 @@ the argument list matches any of the recorded calls to the
spy.
(foo 456 "another param"))
(it "tracks that the spy was called"
- (expect 'foo :to-have-been-called))
+ (expect 'foo :to-have-been-called)
+ (foo 789))
+
+ (it "resets tracking after each spec"
+ (expect 'foo :not :to-have-been-called-with 789))
+
+ (describe "that is defined in a nested `describe'"
+ (before-each
+ (spy-on 'foo :and-return-value 1))
+ (it "will override any outer spy"
+ (expect (foo 789) :to-equal 1)
+ (expect 'foo :not :to-have-been-called-with 123)))
+
+ (it "will not be active outside it's scope"
+ (expect (foo 789) :to-equal nil))
(it "tracks all arguments of its calls"
(expect 'foo :to-have-been-called-with 123)
- [nongnu] elpa/buttercup c100fad 210/340: Implement buttercup-suppress-warning-capture, (continued)
- [nongnu] elpa/buttercup c100fad 210/340: Implement buttercup-suppress-warning-capture, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c994aea 212/340: Add LICENSE file., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d9ce620 213/340: Merge branch 'license-file' into master, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 49f01fc 219/340: Merge branch 'master' into test-emacs-26.3, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 25462dd 223/340: Record calls to spied-on functions that throw errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup bf48137 224/340: Add some tests for error-call recording, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fc19598 225/340: Add examples for checking return value and thrown signal of a spy, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6590360 226/340: Fix a few typos and other small errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8a28489 230/340: Bump version: 1.18 → 1.19, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0e40587 231/340: Tweak the spy-contexts to be more backward compatible, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 60028db 236/340: docs: Clarify the spy lifespan in writing-tests.md,
ELPA Syncer <=
- [nongnu] elpa/buttercup 9c4b473 237/340: test: Add missing apostrophe in spec title, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 90654ec 238/340: Update some docstrings, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 178c795 242/340: README: Add '-L .' to test runner example, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fc4276a 247/340: Make it possible to abort test run cleanly, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup dbcd3d4 256/340: Calculate total test run time with current-time, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c83ba7d 268/340: Extract function buttercup-elapsed-time-string, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 38cfa6f 270/340: Fix spy-on on Emacs 24.3 for symbols that are not fbound, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 81bfed4 272/340: test: Add utility function send-string-to-ansi-buffer, ELPA Syncer, 2021/12/16
- [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