clos-fixtures

2016-08-25

ASDF-loadable fixtures for CLOS classes

Upstream URL

github.com/eudoxia0/clos-fixtures

Author

Fernando Borretti

License

MIT
README

clos-fixtures

Build Status

ASDF-loadable fixtures for CLOS classes.

Usage

Fixture Syntax

(package:class-name
  (:slot-name1 value
   :slot-name2 value)
  (:slot-name1 value
   :slot-name2 value))
(package:another-class
  ...)

Example

(app:user
  (:name "eudoxia"
   :groups (:admin :staff))
  (:name "joe"
   :groups (:admin)))
(app:company
  (:name "Initech"
   :city "Denver"))

register-fixture

This method has to be defined for every class you want to load.

An example using the user model from the last example:

(defmethod clos-fixtures:register-fixture ((user myapp:user))
  (cl-mongo:db.insert "users" (cl-mongo:kv (name user) (groups user))))

Loading from Lisp

(clos-fixtures:load-fixtures
  #P"/path/to/fixture-file")

Loading from ASDF

Simply put this in your components tree (Check clos-fixtures-test.asd for an example):

(:fixture "filename")

Optionally, you can use the :package argument so you don't have to specify the package in the fixture itself. An example from the tests:

(:fixture "molecules" :package :clos-fixtures-test)
(molecule
 (:name "Methane"
  :formula "CH4")
 (:name "Cubane"
  :formula "C8H8"))

License

Copyright (c) 2014-2015 Fernando Borretti (eudoxiahp@gmail.com)

Licensed under the MIT License.

Dependencies (1)

  • fiveam
  • GitHub
  • Quicklisp