Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Custom matcher for promises #181

Open
sbycrosz opened this issue Dec 27, 2015 · 0 comments
Open

Custom matcher for promises #181

sbycrosz opened this issue Dec 27, 2015 · 0 comments

Comments

@sbycrosz
Copy link

Context: I'm testing a Promise created using PromiseKit

What I have now:

promise.then(^(id result){
                            expect(result).to.equal(expected);
                        }).catch(^(NSError *error){ 
                            failure(error);
                        }).finally(^(){
                            done();
                        });

which the lazy old me use as a macro

#define AssertPromise(promise, expected) promise.then(^(id result){ expect(result).to.equal(expected);}).catch(^(NSError *error){ failure(error);}).finally(^(){done();});

What I wanted (similar library in JS: https://github.com/domenic/chai-as-promised/):

expect(promise).to.be.resolvedAs(expected)

Currently I am stuck on implementing the match method of EXPMatcher since it expects a boolean, but then we need to wait until the promise get resolved.

Would this kind of api be possible? Any kind of direction would be nice :)

Cheers,

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant