Denis Kudriashov wrote:
Hi Herby.
There is message #will: which accepts the block with possible arguments
(if needed).
ZnClient stub new will: [ ZnMockClient ...]
But generally your approach looks bad to me. You put too many details on
your tests which just duplicate Zinc API used in the domain code. It
makes tests brittle and tightly coupled. And they looks quite unreadable.
BTW, made it shorter and probably more readable as a result (by also
shortening the test condition):
ZnClient stub new will: [ ZnMockClient
whenRequest: [ :request |
request uri =
('https://onesignal.com/api/v1/players/{1}?app_id={2}' format: { self
uidy: 'Q7'. appId }) asZnUrl
and: [ #(GET HEAD) includes: request method ] ]
thenResponse: [ :request | ZnResponse ok: (ZnEntity json: '{}') ] ].
The reason why I could not test uri as is, is Zinc adding ':443' to it.
But as mentioned, the previous was very unreadable; with asZnUrl it is
probably better.
Herby