Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

More intuitive expectations on blocks #383

Open
dmeehan1968 opened this issue Sep 25, 2013 · 4 comments
Open

More intuitive expectations on blocks #383

dmeehan1968 opened this issue Sep 25, 2013 · 4 comments

Comments

@dmeehan1968
Copy link

I was wondering if anyone had a pattern they used, or if Kiwi has something I'm unaware of, for neatly solving the expectation that a block should be invoked.

I've seen the following pattern suggested for verifying whether a block is called on success, but this seems a bit verbose and unintuitive.

__block BOOL isValid = NO;

[sut doSomethingWithValue: aValue success:^{
    isValid = YES;
}];

[[theValue(isValid) should] beYes];

A bit of playing suggests that block pointers are recognised as Objective-C classes, although not descended from NSObject, which Kiwi expectations need to be applied to.

I was wondering is something like the following might be possible/desirable?

void(^block)(void) = ^{};

[[block should] invoke];

[sut doSomethingWithValue:aValue success:block];

The idea being that you should be able to do variations on:

[[block should] invoke];
[[block shouldNot] invoke];
[[block shouldEventually] invoke];

etc.

Any thoughts?

@stepanhruda
Copy link
Member

It would definitely be a nice matcher. I don't know how to actually tell whether a block has been executed, though.

@supermarin
Copy link

Interesting thoughts.. might take a look into this one

@fcy
Copy link

fcy commented Feb 17, 2014

👍 a way to check if a block was invoked would be awesome

@modocache
Copy link
Member

👍

On Tuesday, February 18, 2014, Felipe Cypriano [email protected]
wrote:

[image: 👍] a way to check if a block was invoked would be awesome

Reply to this email directly or view it on GitHubhttps://github.com/allending/Kiwi/issues/383#issuecomment-35327457
.

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

No branches or pull requests

5 participants