;; ;; %%HEADER%% ;; ;(load "./missbehave.scm") ;(import missbehave) (use missbehave miscmacros) (define (callee . args) 'called) (define (call-it n) (repeat n (callee))) (describe "Missbehave features" (describe "implicit subject" (subject-set! 42) (it should (be 42)) (it should (be a number))) (describe "Simple be matchers" (it "must be true" (expect #t (be true))) (it "must be a string" (expect "hello" (be a string))) (it "can use standard operators" (expect 3 (be > 0))) (it "can use predicates" (expect '() (be null?)))) (describe "Pending" (it "is implicitly pending") (it "is explicitly pending" (pending) (expect '() (be a number)))) (describe "Procedure expectations" (context "Application-count" (it "checks application count" (expect (call-it 1) (call callee once))) (it "checks application count > 1" (expect (call-it 4) (call callee (4 times)))) (it "checks for no calls" (expect (+ 1 1) (call callee never)))) (context "Arguments" (it "checks arguments" (expect (callee 1 2) (call callee (with 1 2)))) (it "mixes arguments and application count" (expect (begin (callee 1 2) (callee 1 2)) (call callee (with 1 2) twice))))) (describe "Procedure stubs" (it "can stub return values" (stub! callee (returns 'not-called)) (expect (callee) (be 'not-called))) (it "provides temporary stubs" (let ((proc (lambda () 'test))) (expect (proc) (be 'test)) (with-stubs! ((proc (returns 'passed))) (expect (proc) (be 'passed))) (expect (proc) (be 'test))))))