branch: elpa/buttercup commit 8e3028403c7da8fac277cefaee2a866841989b0e Author: Jorgen Schaefer <cont...@jorgenschaefer.de> Commit: Jorgen Schaefer <cont...@jorgenschaefer.de>
Disabled suites, pending specs. --- README.md | 35 +++++++++++++++++++++++++++++++++++ ROADMAP.md | 9 +++++++++ buttercup-test.el | 34 ++++++++++++++++++++++++++++++++++ buttercup.el | 31 +++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) diff --git a/README.md b/README.md index db8149b..32c36d5 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,41 @@ walks through the `after-each` functions similarly. (expect foo :to-equal bar)))))) ``` +## Disabling Suites + +Suites and specs can be disabled with the `xdescribe` and `xit` +macros, respectively. These suites and any specs inside them are +skipped when run and thus their results will not appear in the +results. + +```Lisp +(xdescribe "A spec" + (let (foo) + (before-each + (setq foo 0) + (setq foo (1+ foo))) + + (it "is just a function, so it can contain any code" + (expect foo :to-equal 1)))) +``` + +## Pending Specs + +Pending specs do not run. + +Any spec declared with `xit` is marked as pending. + +Any spec declared without a function body will also be marked as +pending in results. + +```Lisp +(describe "Pending specs" + (xit "can be declared using `xit'" + (expect t :to-be nil)) + + (it "can be declared with `it' but without a body")) +``` + ## Test Runners Evaluating `describe` forms just stores the suites. You need to use a diff --git a/ROADMAP.md b/ROADMAP.md index 9431264..ddd76a7 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -50,6 +50,15 @@ Example code: # Version 1.1: The Missing Features +## Pending Specs + +The following phrases were left out from `introduction.js`, and should +be implemented still: + +> Pending specs do not run, _but their names will show up in the results as pending._ + +> And if you call the function `pending` anywhere in the spec body, no matter the expectations, the spec will be marked pending. A string passed to pending will be treated as a reason and displayed when the suite finishes. + ## Return of the Backtrace Suite execution should catch errors and include a backtrace in the diff --git a/buttercup-test.el b/buttercup-test.el index b3e4cb9..1f33e54 100644 --- a/buttercup-test.el +++ b/buttercup-test.el @@ -290,3 +290,37 @@ (expect (buttercup-suite-after-all suite) :to-equal (list 23))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Disabled Suites: xdescribe + +(describe "The `xdescribe' macro" + (it "expands directly to a function call" + (expect (macroexpand '(xdescribe "bla bla" (+ 1 1))) + :to-equal + '(buttercup-xdescribe "bla bla" (lambda () (+ 1 1)))))) + +(describe "The `buttercup-xdescribe' function" + (it "should be a no-op" + (expect (lambda () + (buttercup-xdescribe + "bla bla" + (lambda () (error "should not happen")))) + :not :to-throw))) + +;;;;;;;;;;;;;;;;;;;;;; +;;; Pending Specs: xit + +(describe "The `xit' macro" + (it "expands directly to a function call" + (expect (macroexpand '(xit "bla bla" (+ 1 1))) + :to-equal + '(buttercup-xit "bla bla" (lambda () (+ 1 1)))))) + +(describe "The `buttercup-xit' function" + (it "should be a no-op" + (expect (lambda () + (buttercup-xit + "bla bla" + (lambda () (error "should not happen")))) + :not :to-throw))) diff --git a/buttercup.el b/buttercup.el index f0b2b7f..bb400ad 100644 --- a/buttercup.el +++ b/buttercup.el @@ -330,6 +330,37 @@ form.") (append (buttercup-suite-after-all buttercup--current-suite) (list function)))) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Disabled Suites: xdescribe + +(defmacro xdescribe (description &rest body) + "Like `describe', but mark the suite as disabled. + +A disabled suite is not run." + (declare (indent 1)) + `(buttercup-xdescribe ,description (lambda () ,@body))) + +(defun buttercup-xdescribe (description function) + "Like `buttercup-describe', but mark the suite as disabled. + +A disabled suite is not run." + nil) + +;;;;;;;;;;;;;;;;;;;;;; +;;; Pending Specs: xit + +(defmacro xit (description &rest body) + "Like `it', but mark the spec as disabled. + +A disabled spec is not run." + (declare (indent 1)) + `(buttercup-xit ,description (lambda () ,@body))) + +(defun buttercup-xit (description function) + "Like `buttercup-it', but mark the spec as disabled. + +A disabled spec is not run." + nil) ;; (let* ((buttercup--descriptions (cons description ;; buttercup--descriptions))