ciscoheat / buddy

Your friendly BDD testing library for Haxe!
MIT License
96 stars 24 forks source link

Support metadata for the test spec function #56

Closed kevinresol closed 8 years ago

kevinresol commented 8 years ago

I am trying to use buddy with tink_await, like so:

@:await
class Riders extends BuddySuite {
    @:await public function new() {
        describe('Should work', @:await function() {
            beforeEach(@:await function(done) {
                @:await doSomethingAsync();
                done();
            });

            it('with tink_await', @:await function(done) {
                @:await doSomethingAsync();
                done();
            });
        });
    }
}

In short, I need to be able to add a meta to the test spec function, as in @:await function(done) ...

This is just a PoC so I only modified the macros for describe, beforeEach and it.

P.S. It is a bit repetitive to type buddy.BuddySuite.TestFunc.Async and buddy.BuddySuite.TestFunc.Sync all over the place. Maybe a var sync = macro buddy.BuddySuite.TestFunc.Sync may help. (use as macro beforeEach($sync(someFunc)))

ciscoheat commented 8 years ago

@kevinresol I've made the changes and included the macro (thanks for the tip!), and it seems to work. Here are the tests, if that's all you think is needed, let me know and I'll release a new haxelib version:

https://github.com/ciscoheat/buddy/blob/master/src/buddy/tests/AllTests.hx#L928-L949

kevinresol commented 8 years ago

Yes, that's what I need at this very moment. But I think it is better to support other places as well (e.g. afterEach, etc), to be complete. Thanks for the quick response!

ciscoheat commented 8 years ago

Now it's available on haxelib. And yes it would be nice to have for the whole API. If you have some time for that, please make a PR!