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?
I thought ring.mock
only mocked requests...?
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?
You'd be mocking ajax requests and responses I guess. I'd expect there to be a JS library for that...?
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.
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).
But, yeah, it could certainly be clearer.
Ah, right: the sequence of /-delimited functions broadened the context beyond stubbing. Thx.