Skip to content

Commit

Permalink
Normalize dispatch key of pre-init-spec
Browse files Browse the repository at this point in the history
See #33.
  • Loading branch information
weavejester committed Dec 8, 2017
1 parent 60c7c99 commit e97c4b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/integrant/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
(defmulti pre-init-spec
"Return a spec for the supplied key that is used to check the associated
value before the key is initiated."
identity)
normalize-key)

(defmethod pre-init-spec :default [_] nil)

Expand Down
8 changes: 7 additions & 1 deletion test/integrant/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@
(is (thrown-with-msg?
#?(:clj clojure.lang.ExceptionInfo :cljs cljs.core.ExceptionInfo)
(re-pattern (str "Spec failed on key " ::n " when building system"))
(ig/init {::n (ig/ref ::k), ::k 1.1})))))
(ig/init {::n (ig/ref ::k), ::k 1.1}))))

(testing "with failing composite specs"
(is (thrown-with-msg?
#?(:clj clojure.lang.ExceptionInfo :cljs cljs.core.ExceptionInfo)
(re-pattern (str "Spec failed on key \\[" ::n " " ::nnn "\\] when building system"))
(ig/init {[::n ::nnn] 1.1})))))

(deftest halt-test
(testing "without keys"
Expand Down

0 comments on commit e97c4b3

Please sign in to comment.