diff options
author | Ola Nilsson <ola.nilsson@gmail.com> | 2019-12-21 22:21:43 +0100 |
---|---|---|
committer | Ola Nilsson <ola.nilsson@gmail.com> | 2020-02-24 22:54:36 +0100 |
commit | 521b71bc5814a185888a13b13ca2ba96cd740161 (patch) | |
tree | fc5a3a8e33b1135b989e0cd4f085465ea38a5b82 | |
parent | 9b30c755e43df7045c36e596ce31e0af597b594e (diff) |
Add tests to ensure pending spec state is not overwritten
Any pending spec in an active suite with at least one after-each
function will be marked as passed when buttercup--update-with-funcall
runs the after-each functions. This is an unintended consequence of
0d742b00debd59f07320638c505777f6a908f5ad.
-rw-r--r-- | tests/test-buttercup.el | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el index aa3cd95..843a5ea 100644 --- a/tests/test-buttercup.el +++ b/tests/test-buttercup.el @@ -366,7 +366,46 @@ :not :to-be nil) (expect 'buttercup--set-end-time :to-have-been-called-times 1) (expect (buttercup-suite-or-spec-time-ended spec) - :not :to-be nil))))) + :not :to-be nil)))) + + (it "should not overwrite pending status with `after-each' results" + (with-local-buttercup + (let ((suite (make-buttercup-suite)) + spec) + (let ((buttercup--current-suite suite)) + (after-each (ignore)) + (setq spec (xit "pending"))) + (buttercup--run-suite suite) + (expect (buttercup-spec-status spec) :to-be 'pending)))) + + (describe "should set status to pending" + (it "for assume in `before-each'" + (with-local-buttercup + (describe "suite" + (before-each (assume nil "assume nil in before-each")) + (it "spec" (expect 1 :to-equal 1)) + (after-each (ignore))) + (buttercup-run) + (expect (buttercup-suites-total-specs-pending buttercup-suites) + :to-equal 1))) + (it "for assume in spec" + (with-local-buttercup + (describe "suite" + (before-each (ignore)) + (it "spec" (assume nil "assume nil in spec")) + (after-each (ignore))) + (buttercup-run) + (expect (buttercup-suites-total-specs-pending buttercup-suites) + :to-equal 1))) + (it "for assume in `after-each'" + (with-local-buttercup + (describe "suite" + (before-each (ignore)) + (it "spec" (expect 1 :to-equal 1)) + (after-each (assume nil "assume nil in after-each"))) + (buttercup-run) + (expect (buttercup-suites-total-specs-pending buttercup-suites) + :to-equal 1))))) ;;;;;;;;;;;;;;;;;;;; ;;; Suites: describe @@ -605,12 +644,11 @@ :to-be 'pending))) (it "should set the failure description to PENDING" - (let ((buttercup--current-suite (make-buttercup-suite)) - spec) - (buttercup-xit "bla bla") - (setq spec (car (buttercup-suite-children buttercup--current-suite))) + (let* ((buttercup--current-suite (make-buttercup-suite)) + (spec (buttercup-xit "bla bla"))) (buttercup--update-with-funcall spec (buttercup-spec-function spec)) - (expect (buttercup-suite-or-spec-failure-description spec) :to-equal "PENDING")))) + (expect (buttercup-suite-or-spec-failure-description spec) :to-equal "PENDING") + (expect (buttercup-suite-or-spec-status spec) :to-equal 'pending)))) ;;;;;;;;; ;;; Spies |