mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-01-12 22:51:50 +08:00
Switch to use of Expecta raiseWIthReason matcher after applying fix for crash due to failure to copy blocks
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user