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

raiseException should optionally match on name, reason, and userInfo in Objective-C #26

Closed
modocache opened this issue Aug 31, 2014 · 2 comments

Comments

@modocache
Copy link
Member

Currently I can write the following in Objective-C:

// Objective-C

expectAction(
  [NSException raise:NSRangeException
              format:@"Now you've gone too far!"]
).to(raiseException());

But I can't make an expectation on the name of the exception, nor the reason, nor the userInfo.

In Swift, you can write an expectation that only passes when the name and reason match (with userInfo support coming soon in #12). I think you should be able to do the same in Objective-C.

What should the syntax look like? I like beCloseTo(expected).within(delta). How about the following as a first draft?

expectAction(
  [NSException raise:NSRangeException
              format:@"Now you've gone too far!"]
).to(raiseException().
  named(NSRangeException).
  withReason(@"Now you've gone too far!").
  andUserInfo(@{@"length": @10}));
@jeffh
Copy link
Member

jeffh commented Sep 1, 2014

👍 Maybe without the articles, so reason() and userInfo() is better, but either works for me.

@modocache
Copy link
Member Author

Awesome, thanks! 👍

phatblat pushed a commit to phatblat/Nimble that referenced this issue May 3, 2020
Expose example and example group DSL to specs written in Objective-C.
Internally, QCKDSL.m uses Core.DSL. QCKDSL.h provides complex macros
that "beautify" the class methods.

Addresses the first half of issue Quick#26; the expectations DSL is still not
available in Objective-C.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants