(index ("context" 0) ("context" 134) ("context" 411) ("it" 713) ("it" 840) ("it" 1006) ("it" 1247) ("it" 1379) ("expect" 1558) ("expect" 1839) ("expect" 2310) ("do-not" 2566) ("matcher" 2723) ("be" 3936) ("be" 4008) ("be" 4081) ("be" 4323) ("be" 4477) ("be" 4594) ("close-to" 4847) ("any-of" 5015) ("none-of" 5135) ("list-including" 5258) ("match-string" 5409) ("call" 5895) ("call" 5991) ("call" 6080) ("call" 6170) ("call" 6265) ("call" 6397) ("raise" 6831) ("raise" 6919) ("with-stubs!" 7130) ("returns" 7398))
(def (sig (syntax "(context context-name examples ...)" (id context))) (p "Create a context with the name " (tt "context-name") "."))
(def (sig (syntax "(context context-name (meta (tags ...)) examples ...)" (id context))) (p "Create a context with name " (tt "context-name") " and mark them with " (tt "tags") ". This can be used to filter examples using the --tags command-line switch of " (b "behave") "."))
(def (sig (syntax "(context context-name (meta ((tag . value) ...)) examples ...)" (id context))) (p "Create a context with name " (tt "context-name") " and mark them with the key-value pairs. Those can be used to attach data and to filter them using the --tags command-line-switch of " (b "behave")))
(def (sig (syntax "(it description)" (id it))) (p "Create a pending example with the description set to " (tt "description")))
(def (sig (syntax "(it should matcher)" (id it))) (p "Creates an example that executes " (tt "matcher") " on the current subject. See also " (b "subject-set!") "."))
(def (sig (syntax "(it description expectation ...)" (id it))) (p "Creates an examples with the description set to " (tt "description") " and the  expectations.") (highlight scheme "(it \"is pending\")\n\n(it \"succeeds\"\n  (expect #t))"))
(def (sig (syntax "(it description (meta (tags ...)) expectations)" (id it))) (p "Creates an example with expectations and tags."))
(def (sig (syntax "(it description (meta ((tag . value))) expectations ...)" (id it))) (p "Create an example with expectations and key-value pairs, so that it can be filtered."))
(def (sig (syntax "(expect form)" (id expect))) (p "Create an expection that evaluates form and will fail if " (tt "form") " evaluates to #f and pass otherwise.") (highlight scheme "(it \"succeeds\")\n  (expect (string? \"chickumber\")))\n\n(it \"fails\" )\n  (expect (> 2 3)))"))
(def (sig (syntax "(expect subject to (call arguments ...))" (id expect))) (p "Creates an application-expectation. See also procedure-expections.") (highlight scheme "(define (reverse-list ls)\n  (reverse ls))\n\n(expect (reverse-list (list 1 2 3)) (call reverse)))\n(expect (reverse-list (list 1 2)) (call reverse once)))\n(expect (reverse-list (list 1 2)) (call reverse (with (list 1 2))))\n(expect (reverse-list (list 1 2)) (call reverse (with (list 1 2)) once))\n"))
(def (sig (syntax "(expect subject matcher)" (id expect))) (p "Create an expection on subject with matcher " (tt "matcher") ".") (highlight scheme "(expect (list 1 2) (be a list))\n(expect \"foobar\" (have 6 characters))\n(expect 3.1 (be (close-to 3)))"))
(def (sig (syntax "(do-not (expect ....))" (id do-not))) (p "Creates an expection that fails if its inner " (tt "expectation") " succeeds and vice versa."))
(def (sig (syntax "(matcher (check (subject) check-code) (message (form subject negate) message-code))" (id matcher))) (p "This creates a fresh matcher object. You need to implement both the " (tt "check") " and the " (tt "message") ".") (ul (li "check The check is a procedure that receives one argument, the subject. The subject is a promise so you need to force it if you want to retrieve the value.") (li "message This is the procedure that is invoked to generate the message. It receives three arguments" (ul (li (tt "form") "  This is the quoted form that was passed to expect") (li (tt "subject") "  This is the subject. Again this is a promise so you need to force it to retrieve the actual value.") (li (tt "negate") " Indicates if the check shall be negated. This is set to true if the expect-form has been wrapped into a (do-not) form.")))) (highlight scheme "(define (greater-than x)\n (matcher \n   (check (subject)\n     (> (force subject) x))\n   (message (form subject negate)\n     (if negate\n        (sprintf \"Expected ~A to be less than or equal to ~A\" (force subject) x)\n        (sprintf \"Expected ~A to be greater than ~A\" (force subject) x)))))\n\n(expect 10 (be (greater-than 5)))"))
(def (sig (syntax "(be true)" (id be))) (p "matches if subject is #t"))
(def (sig (syntax "(be false)" (id be))) (p "matches if subject is #f"))
(def (sig (syntax "(be a type)" (id be))) (p "matches if subject is of the specified type. It assumes that there is a procedure type? to check that.") (highlight scheme "(expect \"string\" (be a string))\n(expect (list 1 2 3) (be a list))"))
(def (sig (syntax "(be pred?)" (id be))) (p "matches if pred? evaluates to #t when it is applied to subject") (highlight scheme "(expect 0 (be zero?))"))
(def (sig (syntax "(be value)" (id be))) (p "matches if current subject is equal to value in the sense of equal?."))
(def (sig (syntax "(be pred? value ...)" (id be))) (p "This expands into something like (apply pred? (list subject value ...)). It provides a handy notation to write curried checks.") (highlight scheme "(expect 2 (be > 0))\n(expect -100 (be <=  10))"))
(def (sig (procedure "(close-to value #!key (delta 0.3))" (id close-to))) (highlight scheme "(expect 2 (be (close-to 1))\n(expect  10/3 (be (close-to 3 delta: 0.4))"))
(def (sig (procedure "(any-of value . more-values)" (id any-of))) (highlight scheme "(expect 2 (be (any-of 1 2 3 4))"))
(def (sig (procedure "(none-of value . more-values)" (id none-of))) (highlight scheme "(expect 5 (be (none-of 1 2 3 4))"))
(def (sig (procedure "(list-including value . more-values)" (id list-including))) (highlight scheme "(expect (list 1 2 3) (be (list-including 1 2))"))
(def (sig (procedure "(match-string str #!key (with-matches #f))" (id match-string))) (p "This succeeds if the regular expression represented by " (tt "subject") " matches the string " (tt "str") ". If " (tt "with-matches") " is supplied, it is expected to be an alist holding the expected captures.") (highlight scheme "(expect '(: (+ space) (submatch (+ any))) \n  (match-string \"    test\" with-matches: '((1 . \"test\")))\n\n(expect '(: (+ any)) (match-string \"just a test\"))"))
(def (sig (syntax "(call proc once)" (id call))) (p "matches if proc is called exactly once."))
(def (sig (syntax "(call proc twice)" (id call))) (p "matches if proc is called twice"))
(def (sig (syntax "(call proc never)" (id call))) (p "matches if proc is never called."))
(def (sig (syntax "(call proc (n time))" (id call))) (p "matches if proc is called n times."))
(def (sig (syntax "(call proc (with arg ...))" (id call))) (p "matches if proc is called at least once with the given arguments."))
(def (sig (syntax "(call proc (with arg ...) amount-spec)" (id call))) (p "matches if proc is called with the given arguments and matches the amount-spec which is one of the above (once never (n times)).") (highlight scheme "(define (foo) \"foo\")\n(define (i-call-foo) (foo))\n\n(define (bar x y) \"bar\")\n(define (i-call-bar) (bar 1 2))\n\n(expect (i-call-foo) (call foo once))\n(expect (i-call-bar) (call bar (with 1 2) once))"))
(def (sig (syntax "(raise error)" (id raise))) (p "Matches if subject raises errors."))
(def (sig (syntax "(raise (kind ...))" (id raise))) (p "Matches if subject raises an error and sets the kind-property at least to those specified.") (highlight scheme "(expect (error \"test\") (raise error))"))
(def (sig (syntax "(with-stubs! ((name stub) ... ) code ...)" (id with-stubs!))) (p "This form replaces the behavior of " (b "name") " with the stub code. Note that there is a (returns)-form which is a short-hand to create a procedure that returns the given value."))
(def (sig (procedure "(returns value . more-values)" (id returns))) (p "Creates a procedure that returns value. If you specify multiple value the procedure will return multiple values.") (highlight scheme "(define (return-3) 3)\n(with-stubs! ((return-3 (returns \"not 3\"))\n  (printf \"return-3 returns ~A~%\" (return-3)))"))
