On Apr 22, 2013, at 7:55 PM, Jonathon McKitrick <jmckitr...@gmail.com> wrote:
> I guess the challenge is that the parsing and generating of the structures > from JSON descends to several layers of functions, and the database object is > created and inserted/updated at the lowest level. I've tried a bulk insert > after accumulating records into a higher level function, but sometimes I need > to query for an item previously inserted, so I'm back to inserting each item > as created. The challenge is decoupling object creation from insertion > without breaking the nested process approach. In Midje (https://github.com/marick/Midje), the test would look like this: (fact (parse …json…) => …whatever the function returns… (provided (db/insert …what's to be inserted…) => …whatever insert should return…)) In the case that return values are irrelevant, you'd write that as (fact (parse …json…) => irrelevant (provided (db/insert …what's to be inserted…) => irrelevant)) Read that as "parsing some particular json works provided it calls `insert` with this particular argument." (Usually the required argument will be described literally, but you can also require that the `insert` input match a predicate.) -------- Latest book: /Functional Programming for the Object-Oriented Programmer/ https://leanpub.com/fp-oo -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.