This cool. Because I wanted to use that in one test with a project with my son.
What is the license? Where is the code?

On Tue, Jan 30, 2018 at 11:31 PM, Herbert Vojčík <he...@mailbox.sk> wrote:
> Hi!
>
> I started with a rudimentary HTTP mocking lib (adding features as needed)
> inspired by nock, but using the existing ZnClient / ZnRequest / ZnResponse
> api for mocking.
>
> Atm the feature are very basic (no filtering, matching only by host and
> scheme), but there it is for the interested.
>
> Usage:
>
> setUp
>         "other stuff"
>         Znock default intercept
>
> tearDown
>         "other stuff"
>         Znock default verify
>
> testFooBar
>         'https://foo.bar' znock
>                 url: '/api/v0/info';
>                 get;
>                 ok: (ZnEntity json: self sampleInfoResponse).
>         "code that should get https://foo.bar/api/v0/info";
>
> The setUp starts and cleans the mocker; the test case sets up the
> expectation that GET https://foo.bar/api/v0/info will occur and defines the
> response; tearDown checks that that GET actually appeared and fails if not.
>
> DNU w/ whitelisting is used to reply certain ZnClient messages to set up the
> expectation, ZnResponse class messages to create the response and ZnResponse
> messages to fill it further.
>
> So you can
>
>         'foo.bar' znock
>                 https;
>                 url: '/api/v0/info';
>                 get;
>                 notModified.
>
> if you like it this way or
>
>         'foo.bar' znock
>                 url: '/api/v0/info';
>                 get;
>                 notModified.
>
> to allow both http and https; eventually
>
>         'foo.bar/api/v0/info' znock
>                 get;
>                 notModified.
>
> if you want it shorter; mocking multiple req/res pair should work (not
> tested), as in
>
>         'foo.bar' znock
>                 url: '/api/v0/info';
>                 get;
>                 notModified;
>                 url: '/api/v0/last';
>                 get;
>                 ok: (ZnEntity textCRLF: 'herby').
>
> Both must appear (in any order) for verify to be happy.
>
> Herby
>

Reply via email to