ring

kennytilton 2017-10-30T18:28:33.000392Z

I am working on a client framework and am hoping to find a way to mock responses, not requests. I see a few mentions that ring.mock does that, but no sign of it in the source or doc. Am I just deeply confused?

seancorfield 2017-10-30T18:57:40.000360Z

I thought ring.mock only mocked requests...?

seancorfield 2017-10-30T18:59:43.000045Z

For responses, what sort of things are you looking to mock @hiskennyness? By the time a response reaches the client, isn't just an regular HTTP response, i.e., a bunch of lines of text starting with headers?

seancorfield 2017-10-30T19:00:37.000081Z

You'd be mocking ajax requests and responses I guess. I'd expect there to be a JS library for that...?

kennytilton 2017-10-30T19:42:44.000347Z

Agreed, @seancorfield on the scope of ring mock, but a stack overflow response and the doc for https://github.com/johanhaleby/stub-http itself both cite ring.mock as alternatives to response faking. Now you know why I proposed “deeply confused” as one explanation. 🙂 My test code will be executing a callback hell sequence of Ajax requests (that is the functional capability I am targeting)… hmmm, maybe I need to bring up a cooperating server to truly simulate asynchronous chaos. A fixed test I can hit any public REST API.

seancorfield 2017-10-30T20:01:57.000216Z

I think it's a matter of how you read that doc... "A Clojure library designed to stub HTTP responses regardless of which client library that is used to make the actual HTTP requests. There are several client specific "http mocking/stubbing/faking" libraries out there such as clj-http-fake and ring-mock but they work on the level of the library and not the HTTP level." -- to me that just implies that ring-mock can be used for mocking around Ring (since it mocks how a client behaves in terms of interacting with Ring).

seancorfield 2017-10-30T20:02:12.000112Z

But, yeah, it could certainly be clearer.

kennytilton 2017-10-30T22:37:35.000120Z

Ah, right: the sequence of /-delimited functions broadened the context beyond stubbing. Thx.