 
 (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)))))))
+    (is (expect (:called person)
+                => ["before-create" "before-save" "after-save" "after-create"]))
+    (is (expect (:called (save (remove-called person)))
+                => ["before-update" "before-save" "after-save" "after-update"]))
+    (is (expect (:called (delete (remove-called person)))
+                => ["before-delete" "after-delete"]))))
 
 (deftest test-ensure-indexes
-  (is (empty? (list-indexes Person)))
+  (expect (list-indexes Person) => empty?)
   (ensure-indexes)
   ;; 2 + _id index
-  (is (= 3 (count (list-indexes Person)))))
+  (expect (count (list-indexes Person)) => 3))
 
 (deftest test-references
   (testing "saving"

                      :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)))))
  (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))))
   (let [person (make Person #^{:meta "data"} {:first-name "Jimmy"})]
     (is (= {:meta "data"} (meta person)) "preserves the metadata of original hash")))

(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)))
    (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)))
    (delete person)
    (is (= 5 (count-instances Person)))
    (delete-all Person (where (eq :last-name "Smith1")))
    (is (= 4 (count-instances Person)))
    (delete-all Person)
    (is (= 0 (count-instances Person)))))

(deftest test-callback-protocol
  (are [callback e] (= e (callback e))

  (let [jpmorgan (create Company {:name "JPMorgan Chase & Co." :date-founded "1799"})
        dell (create Company {:name "Dell" :date-founded (date 1984 11 4)})
        exxon (create Company {:name "Exxon" :date-founded "1911"})]
    (expect (older-companies "1800") => [jpmorgan])
    (expect (older-companies "1913") => (in-any-order [jpmorgan exxon]) )
    (expect (older-companies "1913" :sort [(asc :name)]) => [exxon jpmorgan])
    (expect (older-companies "1999" :sort [(asc :date-founded) (asc :name)])
            => [jpmorgan exxon dell])
    (expect (modern-companies) => [dell])))

(deftest test-deffetch-one
  (is (= {:company-by-name company-by-name}
