This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-02
Channels
- # admin-announcements (15)
- # aws (35)
- # beginners (6)
- # boot (183)
- # cider (51)
- # clara (17)
- # cljs-dev (32)
- # clojure (67)
- # clojure-dev (7)
- # clojure-india (1)
- # clojure-japan (3)
- # clojure-norway (1)
- # clojure-russia (26)
- # clojurescript (85)
- # clojurex (4)
- # community-development (1)
- # cursive (18)
- # data-science (1)
- # datomic (46)
- # devcards (29)
- # events (7)
- # funcool (21)
- # hoplon (10)
- # ldnclj (2)
- # lein-figwheel (16)
- # off-topic (60)
- # om (37)
- # onyx (8)
- # re-frame (23)
- # reagent (5)
- # yada (6)
I've used IRC since it involved things like a 2400 baud modem and telneting through a vax. I'm highly sympathetic to the idea that communities shouldn't be wedding themselves to a proprietary service, but it's absurd to argue that IRC provides the same user experience as slack. We need a good FOSS alternative to win uptake, and an organization willing to bear the cost of hosting communities.
Yup, there are a couple good alternatives. But one of them needs to become "the thing"
Hi hivemind, In Java, we have
get("/lotto").then().assertThat().body("lotto.winners.winnerId", hasItems(23, 54));
Any test frameworks can support this like below?
(deftest should-return-200j
(testing "should return 200 ok"
(let [{body :body} (my-app (mock/request :get "/"))]
(is (jsonMatch body "$.foo" "bar")))))
there's this: https://github.com/yeller/matcha, which borrows from Hamcrest heavily. Don't think there's something for HTTP out of the box
json == clojure map
so I would suggest to try something like:
(let [ r (parse (your-service-with-mock)) ] (get-in r [:lotto :winners :winnerId])
and do whatever assertion you need on that node
@thosmos: Thank you so much for the recco on Specter. I was about to rage-code something similar 😉
@lambeta There is also https://github.com/juhakaremo/clj-containment-matchers which takes a bit different approach by comparing whole clojure maps. If comparison is not ok it gives you an diff.
I don't know your use case but often it's more clear to have one assertion comparing full maps than multiple assertions for all the fields
This is an outdated article from march 2010 - https://mmcgrana.github.io/2010/03/clojure-web-development-ring.html note how they pass the var of handler to run-jetty, this is run-jetty at around that time https://github.com/ring-clojure/ring/blob/b4b31e89c84d0ed5251ff78e7e3529f7cef4f297/ring-jetty-adapter/src/ring/adapter/jetty.clj From what I can see at no point is the var derefed, whats going on here?
nvm, you can invoke a var which has a fn as a value, (defn a [] 1) (= (a) (#'a))
(= (a) (@#'a) (#'a))
Hi, so this is my very first clojure code. Fizzbuzz, shortest possible version (letters without whitespaces) (defn m [n] (letfn [(x [d v] (if (= (mod n d) 0) v ""))] (join "" [(x 3 "Fizz") (x 5 "Buzz")]))) To run (map m (range 1 100)) Any tips to make it even shorter ?
@kosecki: tip: you don't normally need letfn
... unless you're writing mutually recursive functions
@pesterhazy: hmm, tried to remove it but there must be different syntax to declare it
` (let myfn (fn [x] ...))
(let [myfn (fn [x] ...)] ...)
@pesterhazy: isn't letfn a shortcut for let ... fn ?
yeah, sort of, but with special magic to allow for mutual recursion
How is one supposed to get a valid line-numbering pushback reader out of clojure.tools.reader
?
(with-open [rdr (io/reader "demo.edn")]
(let [ipbr (clojure.tools.reader.reader-types/indexing-push-back-reader rdr)]
(clojure.tools.reader/read ipbr)))
;; IllegalArgumentException
;; No implementation of method: :read-char
;; of protocol: #'clojure.tools.reader.reader-types/Reader
;; found for class: java.io.BufferedReader
@stuartsierra: a bit counterintuitive but the rdr you pass to ipbr mut be a tools.reader pbr
@bronsa: OK. How do I construct a tools.reader PushbackReader from another java.io.Reader?
@stuartsierra: using a java pbr is fine -- (indexing-push-back-reader (PushbackReader. rdr)) should work
@bronsa: OK, thanks.
That appears to work.
@bronsa: So I have a couple of feature requests for you … … Make
clojure.tools.reader.reader-types
more evident, and make the types java.io.Closeable for use in with-open
.
@stuartsierra: both reasonable requests, I've wanted to go other the reader-types hierarchy for a while and better the interop story
@bronsa: Cool, thanks!
FWI, this came up because I was replacing clojure.core/read
with clojure.tools.reader/read
for better line/column reporting in errors, so thanks for that!
@stuartsierra: I’m interested, this might be relevant for my conj talk - are you monkeypatching read for general Clojure code?
@stuartsierra: https://github.com/clojure/tools.reader/commit/bc8249eb4654eaddaaf9600876c2e77be2f4ba16 https://github.com/clojure/tools.reader/commit/fd9f62f6fbb4a2b048e32b540727df548f3a5d96
(with-open [rdr (indexing-push-back-reader (io/reader file))] (read rdr))
should work now
@cfleming: I'm using read
to read Datomic transaction data.
@bronsa Nice, that's what I was looking for earlier
@stuartsierra: let me know if there's anything else -- I was talking with @alexmiller the other day about releasing tools.reader 1.0 so if there's any features you're interested I'd like to implement them ASAP
I don't really interop tools.reader with java readers so I'm not aware of all the possible use-cases
@bronsa I don't use it all that heavily, so I'm not an ideal test user.
@michaelklishin: I'm using monger and I've discovered that my calls to update are resulting in the thread staying open indefinitely (until I shut down my whole app) - seemingly waiting to read a result from mongo and not getting one (oddly, the socket isn't closed - the socket is open but no reply is written) - does this sound like any known issue? could this be caused by a misconfiguration of write concerns maybe?
I have profiling dumps that show another new thread that stays open for the rest of the lifetime of the app for each time I call update
@kosecki: Here's mine, tweet sized:
(map (fn [i f b] (if (or f b) (str f b) i))
(range 1 101)
(cycle [nil nil "FIZZ"])
(cycle [nil nil nil nil "BUZZ"]))
@hlship: how about (or (not-empty (str f b)) i)
maybe your if is clearer
@noisesmith: that's tighter but yes not-empty and String is a bit obscure.
@hlship: which is funny, because my main usage of not-empty is to reject empty strings since seq ruins their stringiness
if anyone has used clj-webdriver, I'd much appreciate opinions on this -> https://github.com/semperos/clj-webdriver/issues/156