                       :address {:city "Nashville"
                                 :street {:number "123"
                                          :name "Main St."}}})]
-    (is (= Address (class (-> person :address))))
-    (is (= Street (class (-> person :address :street))))
-    (is (= Phone (class (-> person :phones first)))))
+    (expect (class (-> person :address)) => Address)
+    (expect (class (-> person :address :street)) => Street)
+    (expect (class (-> person :phones first))=> Phone))
   (let [person (make Person {:last-name "Smith"})
         phone (make Phone {})]
-    (is (= #{:last-name :blood-alcohol-level} (set (keys person))))
-    (is (= 0.0 (:blood-alcohol-level person)))
-    (is (= #{:country-code} (set (keys phone))))
-    (is (= 1 (:country-code phone))))
+    (expect (keys person) => (in-any-order [:last-name :blood-alcohol-level]))
+    (expect (:blood-alcohol-level person) =>  0.0)
+    (expect (keys phone) => [:country-code])
+    (expect (:country-code phone) => 1))
+  (testing "preserves the metadata of original hash")
    (let [person (make Person #^{:meta "data"} {:first-name "Jimmy"})]
-     (is (= {:meta "data"} (meta person)) "preserves the metadata of original hash")))
+     (expect (meta person) => {:meta "data"})))
+
+(defn remove-called [e] (dissoc e :called))
 
 (deftest test-crud
-  (let [person (dissoc (create Person
-                               {:first-name "John"
-                                :last-name "Smith"
-                                :birthday (date 1976 7 4)
-                                :phones [{:number "123" :country-code 2}]
-                                :address {:city "Nashville"
-                                          :street {:number "123"
-                                                   :name "Main St."}}})
-                       :called)]
-    (is (= Person (class person)))
-    (is (= "1976-07-04" (:birthday person)))
-    (is (not (nil? (:_id person))))
-    (is (= (collection :people) (collection-for Person)))
-    (is (= (collection :people) (collection-for person)))
-    (is (= person (dissoc (fetch-by-id Person (:_id person)) :called)))
-    (is (= person (dissoc (first (fetch-all Person))
-                          :called)))
-    (is (= person (dissoc (first (fetch Person (where (eq :last-name "Smith"))))
-                          :called)))
-    (is (= 1 (count-instances Person)))
+  (let [person (remove-called (create Person
+                                      {:first-name "John"
+                                       :last-name "Smith"
+                                       :birthday (date 1976 7 4)
+                                       :phones [{:number "123" :country-code 2}]
+                                       :address {:city "Nashville"
+                                                 :street {:number "123"
+                                                          :name "Main St."}}}))]
+    (expect (class person) => Person)
+    (expect (:birthday person) => "1976-07-04")
+    (expect (:_id person) => not-nil?)
+    (expect (collection-for Person) => (collection :people))
+    (expect (collection-for Person) => (collection-for person))
+    (expect (remove-called (fetch-one Person (where (eq :_id (:_id person)))))
+            => person)
+    (expect (remove-called (first (fetch-all Person)))
+            => person)
+    (expect (remove-called (first (fetch Person (where (eq :last-name "Smith")))))
+            => person)
+    (expect (count-instances Person) => 1)
     (dotimes [x 5]
       (create Person {:first-name "John" :last-name (str "Smith" (inc x))}))
-    (is (= "John" (first (distinct-values Person :first-name))))
-    (is (= 6 (count-instances Person)))
+    (expect (first (distinct-values Person :first-name)) => "John")
+    (expect (count-instances Person) => 6)
     (delete person)
-    (is (= 5 (count-instances Person)))
+    (expect (count-instances Person) => 5)
     (delete-all Person (where (eq :last-name "Smith1")))
-    (is (= 4 (count-instances Person)))
+    (expect (count-instances Person) => 4)
     (delete-all Person)
-    (is (= 0 (count-instances Person)))))
+    (expect (count-instances Person) => 0)))
 
 (deftest test-callback-protocol
   (are [callback e] (= e (callback e))


(deftest test-callback-impls
  (let [person (create Person {:first-name "John" :last-name "Smith"})]
    (is (= ["before-create" "before-save" "after-save" "after-create"]
             (:called person)))
    (is (= ["before-update" "before-save" "after-save" "after-update"]
             (:called (save (dissoc person :called)))))
    (is (= ["before-delete" "after-delete"]
             (:called (delete (dissoc person :called)))))))

(deftest test-ensure-indexes
  (is (empty? (list-indexes Person)))
  (ensure-indexes)
  ;; 2 + _id index
  (is (= 3 (count (list-indexes Person)))))

(deftest test-references
  (testing "saving"

       [:keyword 'not-a-map-or-keyword]))

(deftest test-entity-spec
  (doseq [e [Address Phone Person]]
    (expect e => not-nil?)))

(deftest test-entity-spec-in
  (expect (entity-spec-of Person :address) => (entity-spec Address))
  (expect (entity-spec-of Person :phones) => (entity-spec java.util.List))
  (expect (entity-spec-of-item Person :phones) => (entity-spec Phone))
  (expect (entity-spec-of Person :address :street) => (entity-spec Street)))

(deftest test-collection-name
  (testing "default name"
    (expect (:collection-name (entity-spec Person)) => "people"))
  (testing "override name"
    (expect (:collection-name (entity-spec Simple)) => "simpletons")))

(deftest test-make
  (let [phone (make Phone {:number "555-555-1212"})]
    (expect (class phone) => Phone))
  (let [address (make Address {:city "Nashville"
                               :street {:number "123"
                                        :name "Main St."}})]
    (expect (class address) => Address)
    (expect (class (:street address)) => Street))
  (let [person (make Person
                     {:first-name "John"
                      :last-name "Smith"
