Guile-spec is an RSpec/Jasmine-like BDD testing library for Guile Scheme.
Test suites encapsulate test cases, called specs. Test suites are
created with the
describe forms can be nested.
(describe "guile-spec README" ...)
Specs contain expectations of the code under test. Specs are created
it form within a
(describe "guile-spec README" (it "provides useful information") ...)
A spec must have all true expectations to pass. Any predicate can be used as a matcher.
(describe "guile-spec README" (it "provides useful information" (let ((information "useful")) (expect string=? (readme) information))))
Stubs are used to better isolate the code under test. The
inserts a procedure into a module that returns an arbitrary value,
replacing what was there before. The previous binding is restored
before leaving the form.
Syntax-wise, it resembles a
let form, but with a module name before
the list of stubbed procedures.
(stub (module name) ((procedure-name (return value)) ...) ...)
return form is optional.
#f is returned by default.
(describe "guile-spec README" (let ((val "foo")) (stub (guile-spec README) ((stubbing-section (return val))) (it "has a section about stubbing" (expect string=? (stubbing-section) val)))))
(describe "#append" (it "concatenates 2 or more lists" (let ((a '(1)) (b '(2)) (c '(3))) (expect equal? (append a b c) '(1 2 3)))))
Things that are missing
- good debug information
- error handling
- colored output
$ guile-spec spec/my_spec.scm
Note: the result of calling
load on a spec file must be a
There are tons of features missing to make this a real BDD library. Patches welcome.