cljs.spec is not stable or in sync with Clojure 1.9.0-alpha10 clojure.spec yet. Working on that. Until then you should only experiment with what's there and avoid attempting anything serious.
On Tue, Jul 26, 2016 at 7:40 AM, <[email protected]> wrote: > Hi, > > I'm little bit puzzled and didn't find a proper way how to integrate > clojure.spec with clojure.test yet. My env is ... > > - testing via doo in node > - got some cljs.test tests, run by run-tests macro from cljs.test > - wrote sample function spec > > ... > > (s/def ::path > (s/with-gen (s/and string? #(string/starts-with? % "/")) > #(gen/fmap (fn [s] (let [i (rand-int 1024)] > (if (odd? i) (str "/" s) s))) > (gen/string)))) > > (s/def ::method #{"GET" "POST" "DELETE"}) > (s/def ::role #{"*" "owner" "admin" "member"}) > (s/def ::endpoint (s/keys :req-un [::path ::method ::role])) > (s/def ::endpoints (s/* ::endpoint)) > (s/def ::variables (s/nilable (s/map-of string? string?))) > > (s/def ::ret-path (s/and string? #"^/(GET|POST|DELETE)/")) > (s/def ::ret-paths (s/* ::ret-path)) > > (s/fdef endpoints->paths > :args (s/cat :endpoints ::endpoints :role ::role :variables ::variables) > :ret ::ret-paths > :fn #(<= (count (:ret %)) (count (-> % :args :endpoints)))) > > ... I can check it manually via ... > > (cljs.spec.test/check-fn endpoints->paths (s/spec > 'auth.util.endpoint/endpoints->paths)) > > ... and it works. I tried to integrate it with cljs.test and it fails. > When I tried to run-all-tests (cljs.spec.test), I can see that the function > spec was executed / tested, but testing didn't fail when there was an error > in spec / function. > > <testing-output> > ... > Testing auth.util.endpoint-test > > Ran 6 tests containing 23 assertions. > 0 failures, 0 errors. > Checking #'auth.util.endpoint/endpoints->paths > {:result {:cljs.spec/problems {[] {:pred string?, :val 1, :via > [:auth.util.endpoint/ret-paths :auth.util.endpoint/ret-paths > :auth.util.endpoint/ret-path :auth.util.endpoint/ret-path], :in [0]}}, > :failed-on :ret}, :seed 1469520712557, :failing-size 0, :num-tests 1, :fail > [("admin" {})], :shrunk {:total-nodes-visited 2, :depth 1, :result > {:cljs.spec/problems {[] {:pred string?, :val 1, :via > [:auth.util.endpoint/ret-paths :auth.util.endpoint/ret-paths > :auth.util.endpoint/ret-path :auth.util.endpoint/ret-path], :in [0]}}, > :failed-on :ret}, :smallest [("owner" nil)]}} > </testing-output> > > ... cljs.test tests are executed, failures / errors counted properly. > cljs.spec tests are executed, but no proper failures / errors counters and > testing itself didn't fail. Tried to integrate them in a way that I was > checking output of check-fn in deftest body, testing failed properly, but > no info why the test failed because of simple boolean test in is. > > I'm probably overlooking something. What is the proper way to: > > - test in node via doo > - execute cljs.test tests > - execute all cljs.spec tests > - fail testing if cljs.spec tests failed and display why (explain) and > correct number of failures / errors > > Many thanks, > Robert > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to the Google Groups > "ClojureScript" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/clojurescript.
