Switch to use of Expecta raiseWIthReason matcher after applying fix for crash due to failure to copy blocks

This commit is contained in:
Blake Watters
2013-01-15 09:14:11 -05:00
parent 259e6c2fe5
commit 260d01a1b0

View File

@@ -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