Many modifications #12

Closed
wants to merge 11 commits into
from

Projects

None yet

2 participants

@hartbit
Contributor
hartbit commented Mar 7, 2012

Improved the naming convention

Not becomes toNot
to is a new no-op
isGoing becomes will
isNotGoing becomes willNot

expect(var).equal(5);
expect(var).to.equal(5);
expect(var).toNot.equal(4);
expect(var).will.equal(5);
expect(var).willNot.equal(4);

Changed the contain matcher to work with any NSFastEnumeration class

Now, the contain matcher works with NSString and any class that conforms to the NSFastEnumeration protocol. Therefore, it works with NSSet, and with NSDictionary. Currently, it will only match key-value pairs with NSDictionary. Perhaps we need haveKey/haveValue matchers specifically for NSDictionary.

Fix ARC error with the beIdenticalTo matcher

With projects using ARC, the beIdenticalTo matcher caused an error if the expected value is of type id, as ARC does not allow implicitly casting from id to void*. I added a beIdenticalTo macro that explicitly does a bridge cast.

Fixed a false negative bug with negative asynchronous

When expecting an asynchronous negative, if the matchBlock returns true, we will return a fail before waiting the timeout. I modified the asynchronous tests to fail with that bug and fixed the bug by taking into account the negative in the asynchronous loop.

David Hart added some commits Mar 7, 2012
David Hart Fixed a false negative bug with asynchronous negatives
When expecting an asynchronous negative, if the matchBlock returns
true, we will return a fail before waiting the timeout. I modified the
asynchronous tests to fail with that bug and fixed the bug by taking
into account the negative in the asynchronous loop.
c7c3e7b
David Hart Improved the naming convention. 177811f
David Hart Added beCloseTo matcher. 6229f4e
David Hart Missing beCloseTo import 55f55ea
David Hart Renamed test classes to correspond to the new naming scheme. 7e7482d
David Hart Removed a ghost of the exception handling in the project file. 64b8a0e
David Hart Updated to README to show the new modifications b418527
David Hart Added the ability for the contain matcher to use any NSFastEnumeratio…
…n object.
efa56e3
David Hart Upgraded to Xcode 4.3 e48fc10
David Hart Fix ARC warning and avoid having to bridge id objects fcb91db
David Hart Added a beCountOf matcher for collections fa90b27
@petejkim
Member

Hey I am sorry. I don't know how I missed this. Changes look good, but is this backwards-compatible?

@petejkim
Member

If it isn't I might have to increment major version number and add some more features :P

@hartbit
Contributor
hartbit commented Mar 26, 2012

Changes look good, but is this backwards-compatible?

Unfortunately not. As I took the liberty of changing the naming convention heavily, I thought it was best not to leave two conventions in parallel. What do you think?

If it isn't I might have to increment major version number and add some more features :P

I'm also planning on adding a conformToProtocol matcher.

By the way, I spent a while trying to implement exception matching like so:

expect([object methodCall]).to.raise();
expect([object methodCall:nil]).to.raiseException(@"NSInvalidArgumentException");

But I got stuck for several reasons. First of all, the expect macro expects an expression that returns a value. Of course, that can be fixed by wrapping the calls in a block like this, but it's not very elegent:

expect(^{ [object methodCall] }).to.raise();
expect(^{ [object methodCall:nil] }).to.raiseException(@"NSInvalidArgumentException");

But I got another problem implementing the asynchronous matching:

expect(^{ [object methodCall] }).will.raise();

Indeed, I wrapped the calls to the run loop in a try/catch block, but it seems that exceptions that happened did not get caught by that try/catch block. Any ideas?

@petejkim petejkim closed this Mar 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment