This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-08
Channels
- # announcements (7)
- # babashka (44)
- # beginners (162)
- # cider (22)
- # clara (11)
- # clj-kondo (14)
- # cljsrn (8)
- # clojure (91)
- # clojure-dev (24)
- # clojure-europe (6)
- # clojure-france (4)
- # clojure-italy (11)
- # clojure-nl (4)
- # clojure-spec (11)
- # clojure-uk (14)
- # clojurescript (92)
- # community-development (1)
- # core-logic (1)
- # cryogen (1)
- # cursive (6)
- # data-science (3)
- # datahike (3)
- # datomic (32)
- # degree9 (3)
- # dirac (3)
- # emacs (9)
- # eql (1)
- # events (1)
- # find-my-lib (1)
- # fulcro (67)
- # graphql (13)
- # helix (9)
- # jobs (1)
- # jobs-discuss (92)
- # leiningen (31)
- # malli (8)
- # meander (3)
- # news-and-articles (1)
- # off-topic (46)
- # pathom (2)
- # practicalli (1)
- # re-frame (52)
- # reitit (12)
- # shadow-cljs (40)
- # spacemacs (10)
- # sql (4)
- # xtdb (8)
After quite bit of experimentation, I refactored my specs, code and tests for a bank account and learnt a bit about qualified keys and auto-resolve macro. I have specs that I can use with my clojure.test unit tests
I updated the journal to show how I would create the specs, unit tests and code now https://github.com/practicalli/leveraging-spec/blob/master/src/practicalli/bank_account_design_journal.clj
And the specs are in their own namespace, using a Clojure Common extension, .cljc
(I believe all the specs are host neutral)
https://github.com/practicalli/leveraging-spec/blob/master/test/practicalli/bank_account_spec.cljc
@U05254DQM Is this a deliberate bug to fall out of testing later? https://github.com/practicalli/leveraging-spec/blob/master/src/practicalli/bank_account_design_journal.clj#L56
:args
should be a sequence spec, using s/cat
: https://github.com/practicalli/leveraging-spec/blob/master/src/practicalli/bank_account_design_journal.clj#L422
Do you understand why this doesn't work? https://github.com/practicalli/leveraging-spec/blob/master/src/practicalli/bank_account_design_journal.clj#L337-L344
s/or
requires labels for the alternatives: (s/or :qualified (s/keys :req [...]) :unqualified (s/keys :req-un [...]))
Oh yes, labels. At 2.30am I tend to forget things :white_frowning_face: I find fdef a bit opaque, some more reading and experimenting to do. Thanks for spotting the bug in last-name, not intentional. Thanks for the review
I got the spec/or
expression to wrap the :req
and :req-un
versions working.
I have my fdef :args validating after instrumenting.
Still working on testing the :ret
in the fdef...
Right, :args
is for instrument
-- checking that your code is calling the function correctly -- and :ret
/`:fn` are for generative testing, to make sure your function behaves correctly.
With instrument
, :ret
and :fn
are ignored. With check
, :args
is used to generate conforming arguments and then the function is called and the :ret
and :fn
specs are checked against the return value and against the arguments/return value respectively.
A lot of people don't feel the docs are clear enough about :args
/`instrument` and :ret
/`:fn`/`check`
I’m comfortable with instrument for now. I don’t seem to have something right with check yet, but will look again tomorrow. Thanks.