From 260d01a1b0da8e9545cd10857587d37fd46aa93e Mon Sep 17 00:00:00 2001 From: Blake Watters Date: Tue, 15 Jan 2013 09:14:11 -0500 Subject: [PATCH] Switch to use of Expecta `raiseWIthReason` matcher after applying fix for crash due to failure to copy blocks --- .../CoreData/RKConnectionDescriptionTest.m | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/Tests/Logic/CoreData/RKConnectionDescriptionTest.m b/Tests/Logic/CoreData/RKConnectionDescriptionTest.m index 3b05d1bd..7e237819 100644 --- a/Tests/Logic/CoreData/RKConnectionDescriptionTest.m +++ b/Tests/Logic/CoreData/RKConnectionDescriptionTest.m @@ -15,24 +15,6 @@ @implementation RKConnectionDescriptionTest -- (void)expectBlock:(void (^)(void))block toRaise:(NSString *)exceptionName reason:(NSString *)reason -{ - NSException *caughtException = nil; - @try { - block(); - } - @catch (NSException *exception) { - caughtException = exception; - } - @finally { - expect(caughtException).notTo.beNil(); - if (caughtException) { - if (exceptionName) expect([caughtException name]).to.equal(exceptionName); - if (reason) expect([caughtException reason]).to.equal(reason); - } - } -} - - (void)setUp { [RKTestFactory setUp]; @@ -53,34 +35,22 @@ - (void)testInitWithNilAttributesRaisesError { -// expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@"Invalid parameter not satisfying: attributes"]; }).to.raise(NSInternalInconsistencyException); - [self expectBlock:^{ - RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:nil]; - } toRaise:NSInternalInconsistencyException reason:@"Invalid parameter not satisfying: attributes"]; + expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:nil]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Invalid parameter not satisfying: attributes"); } - (void)testInitWithEmptyAttributesDictionaryRaisesError { -// expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{}]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Cannot connect a relationship without at least one pair of attributes describing the connection"); - [self expectBlock:^{ - RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{}]; - } toRaise:NSInternalInconsistencyException reason:@"Cannot connect a relationship without at least one pair of attributes describing the connection"]; + expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{}]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Cannot connect a relationship without at least one pair of attributes describing the connection"); } - (void)testInitWithAttributeThatDoesNotExistInEntityRaisesError { -// expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{ @"invalidID": @"catID" }]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Invalid parameter not satisfying: relationship"); - [self expectBlock:^{ - RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{ @"invalidID": @"catID" }]; - } toRaise:NSInternalInconsistencyException reason:@"Cannot connect relationship: invalid attributes given for source entity 'Human': invalidID"]; + expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{ @"invalidID": @"catID" }]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Cannot connect relationship: invalid attributes given for source entity 'Human': invalidID"); } - (void)testInitWithAttributeThatDoesNotExistInDestinationEntityRaisesError { -// expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{ @"favoriteCatID": @"invalid" }]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Invalid parameter not satisfying: relationship"); - [self expectBlock:^{ - RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{ @"favoriteCatID": @"invalid" }]; - } toRaise:NSInternalInconsistencyException reason:@"Cannot connect relationship: invalid attributes given for destination entity 'Cat': invalid"]; + expect(^{ RKConnectionDescription __unused *connection = [[RKConnectionDescription alloc] initWithRelationship:self.relationship attributes:@{ @"favoriteCatID": @"invalid" }]; }).to.raiseWithReason(NSInternalInconsistencyException, @"Cannot connect relationship: invalid attributes given for destination entity 'Cat': invalid"); } @end