Denis Kudriashov wrote:
Hi Herbert.

It is a bit experimental API to allow more descriptive failures. Evaluate following code:


    (2@3) where x should equal: 10

It will give you failure message: Got "2" from (2@3) x but it should equal "10".
But without #where it would be: Got "2" but it should equal "10".

And it works with long message chains:

    (2@3 corner: 10@30) where origin x should equal: 10

It will show: Got "2" from (2@3) corner: (10@30) origin x but it should equal "10".

So in my case, I could see difference in something like this?

        responseCheck := (znClient
username: (self uidy: 'Q7') asString, '/TEST' password: 'tk';
                timeout: 1; post; response) where.
        responseCheck should be isSuccess.
responseCheck where contentType should equal: ZnMimeType applicationJson.
        responseCheck where entity should not be: nil.

In that case it would be nice to be able to write something like:

        (znClient
username: (self uidy: 'Q7') asString, '/TEST' password: 'tk';
                timeout: 1; post; response) where: [ :response |
        response should be isSuccess.
response where contentType should equal: ZnMimeType applicationJson.
        response where entity should not be: nil ].

I am still not sure is it good approach or not. But that is idea.
Besides It is possible to retrieve such information using magic with thisContext and reflectivity. But again the question is same: does it really make sense to do it for assertions?

Best regards,
Denis



2018-05-04 16:28 GMT+03:00 Herbert Vojčík <he...@mailbox.sk <mailto:he...@mailbox.sk>>:

    Hello,

    When I am writing tests using Mocketry's DSL, I get puzzled about
    how / when to use #where, and how is it different when it's used and
    when it is not?

    As far as i tried, I did not find any difference. That is, pasting
    part of one of my tests:

             response := znClient
                     username: (self uidy: 'Q7') asString, '/TEST'
    password: 'tk';
                     timeout: 1; post; response.
             response should be isSuccess.
             response where contentType should equal: ZnMimeType
    applicationJson.
             response where entity should not be: nil.
             (STON fromString: response entity contents) should equal: nil

    I get the same result (pass if ok, failure with DNU when thing is
    not present) whether `where` is there or isn't.

    Could you explain what is it's purpose and correct usage?

    Thanks, Herby



Reply via email to