Fork me on GitHub
#clojure
<
2015-11-02
>
jasonwatkinspdx06:11:03

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.

rm06:11:40

here is one

jasonwatkinspdx06:11:58

Yup, there are a couple good alternatives. But one of them needs to become "the thing"

jsyeo06:11:55

discord looks promising tho

lambeta08:11:27

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")))))

dm308:11:44

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

lambeta08:11:33

seems not support jsonPath syntax

dm308:11:10

no, you'd have to extend it

lambeta09:11:57

which lib is good for jsonPath if I want to extend it in matcha

dm309:11:59

guess something from java?

dm309:11:20

you could just wrap whatever lib you were using there

danlebrero09:11:52

json == clojure map

danlebrero09:11:08

so I would suggest to try something like:

danlebrero09:11:47

(let [ r (parse (your-service-with-mock)) ] (get-in r [:lotto :winners :winnerId])

danlebrero09:11:01

and do whatever assertion you need on that node

bradford09:11:03

@thosmos: Thank you so much for the recco on Specter. I was about to rage-code something similar 😉

thosmos09:11:23

@bradford: I'm glad to contribute in some way to your happiness simple_smile

bradford10:11:04

BTW is anyone here in #antwerp? I’m travelling and could use some code amigos.

mhjort10:11:44

@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.

mhjort10:11:01

And you can ignore some of the fields from comparison

mhjort10:11:54

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

nowprovision11:11:25

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?

nowprovision11:11:40

nvm, you can invoke a var which has a fn as a value, (defn a [] 1) (= (a) (#'a))

nowprovision11:11:21

(= (a) (@#'a) (#'a))

kosecki12:11:28

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 ?

mbertheau13:11:56

@kosecki: I propose that this metric is commonly uninteresting simple_smile

pesterhazy13:11:44

@kosecki: tip: you don't normally need letfn

pesterhazy13:11:09

... unless you're writing mutually recursive functions

kosecki13:11:23

@pesterhazy: hmm, tried to remove it but there must be different syntax to declare it

pesterhazy13:11:47

` (let myfn (fn [x] ...))

pesterhazy13:11:11

(let [myfn (fn [x] ...)] ...) 

kosecki13:11:30

@pesterhazy: isn't letfn a shortcut for let ... fn ?

pesterhazy13:11:04

yeah, sort of, but with special magic to allow for mutual recursion

Lambda/Sierra19:11:51

How is one supposed to get a valid line-numbering pushback reader out of clojure.tools.reader?

Lambda/Sierra19:11:21

(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

bronsa19:11:27

@stuartsierra: a bit counterintuitive but the rdr you pass to ipbr mut be a tools.reader pbr

bronsa19:11:33

or even a java pbr

Lambda/Sierra19:11:34

@bronsa: OK. How do I construct a tools.reader PushbackReader from another java.io.Reader?

bronsa19:11:27

@stuartsierra: using a java pbr is fine -- (indexing-push-back-reader (PushbackReader. rdr)) should work

Lambda/Sierra19:11:44

That appears to work.

Lambda/Sierra19:11:15

@bronsa: So I have a couple of feature requests for you … simple_smile … Make clojure.tools.reader.reader-types more evident, and make the types java.io.Closeable for use in with-open.

bronsa19:11:52

@stuartsierra: both reasonable requests, I've wanted to go other the reader-types hierarchy for a while and better the interop story

bronsa19:11:05

hopefully I'll have some time this week to do it

Lambda/Sierra19:11:11

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!

cfleming20:11:47

@stuartsierra: I’m interested, this might be relevant for my conj talk - are you monkeypatching read for general Clojure code?

cfleming20:11:13

Or are you just using c.t.r/read in code you’re using to analyze something?

bronsa20:11:21

(with-open [rdr (indexing-push-back-reader (io/reader file))] (read rdr)) should work now

Lambda/Sierra20:11:04

@cfleming: I'm using read to read Datomic transaction data.

Lambda/Sierra20:11:52

@bronsa Nice, that's what I was looking for earlier simple_smile

bronsa20:11:07

@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

bronsa20:11:52

I don't really interop tools.reader with java readers so I'm not aware of all the possible use-cases

Lambda/Sierra20:11:31

@bronsa I don't use it all that heavily, so I'm not an ideal test user.

noisesmith21:11:36

@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?

noisesmith21:11:43

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

hlship22:11:20

@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"]))

pmooser22:11:17

cute idea with the cycles

noisesmith22:11:22

@hlship: how about (or (not-empty (str f b)) i)

noisesmith22:11:26

maybe your if is clearer

hlship22:11:15

@noisesmith: that's tighter but yes not-empty and String is a bit obscure.

noisesmith23:11:08

@hlship: which is funny, because my main usage of not-empty is to reject empty strings since seq ruins their stringiness

stopa23:11:39

if anyone has used clj-webdriver, I'd much appreciate opinions on this -> https://github.com/semperos/clj-webdriver/issues/156