it-agile/dahlia

Support async testing

Opened this issue · 2 comments

Hi,

I'm using Dahlia while writing an asynchronous Redis library. I'd like to add a waitsFor() block similair to that used by Jasmine:

https://github.com/pivotal/jasmine/wiki/Asynchronous-specs

In Dahlia I would imagine an async test would resemble this:

describe("my async thing", () {
    it("should return a value to a callback", () {
        var conn = Redis.connect("localhost"),
            ret_val;

        conn.get("key").then((val) => ret_val = key);

        waitFor(() => return ret_val != null, 5000);

        run(() {
            expect(ret_val).to(equal("value"));
        });
    });
});

Any thoughts on this? If you're open to it I'd be willing to take this on as one of my first Dart projects but wanted to get your input first.

NOTE: That's just a trivial example more to show the syntax than a use case.

Thanks!

I haven't given asynchronous testing any thought yet, because I myself prevent having the need for it by mocking away the parts that would need it.

But it doesn't look obtrusive. So fork dahlia, implement it and send a pull request when you're done.

Cheers,
Robert

Sounds good @rbeeger. I've also written another matcher that can be used to compare List. I'll submit a separate pull request for that which you can merge if you're interested.