mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Updated mapping test API for 0.20
* Reimplemented connection tests to work with `RKConnectionDescription`. Introduced new `RKConnectionTestExpectation` class * Slimmed down API by removing proxy methods on `RKMappingTest` * Eliminated `verifiesOnExpect` behavior in favor of using `evaluateExpectation:` * Ensured compatibility with RKKiwiMatchers
This commit is contained in:
66
Code/Testing/RKConnectionTestExpectation.m
Normal file
66
Code/Testing/RKConnectionTestExpectation.m
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// RKConnectionTestExpectation.m
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 12/8/12.
|
||||
// Copyright (c) 2012 RestKit. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <CoreData/CoreData.h>
|
||||
#import "RKConnectionTestExpectation.h"
|
||||
#import "RKObjectUtilities.h"
|
||||
|
||||
@interface RKConnectionTestExpectation ()
|
||||
@property (nonatomic, copy, readwrite) NSString *relationshipName;
|
||||
@property (nonatomic, copy, readwrite) NSDictionary *attributes;
|
||||
@property (nonatomic, strong, readwrite) id value;
|
||||
@end
|
||||
|
||||
@implementation RKConnectionTestExpectation
|
||||
|
||||
+ (id)expectationWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value
|
||||
{
|
||||
return [[self alloc] initWithRelationshipName:relationshipName attributes:attributes value:value];
|
||||
}
|
||||
|
||||
- (id)initWithRelationshipName:(NSString *)relationshipName attributes:(NSDictionary *)attributes value:(id)value
|
||||
{
|
||||
NSParameterAssert(relationshipName);
|
||||
NSAssert(value == nil ||
|
||||
[value isKindOfClass:[NSManagedObject class]] ||
|
||||
RKObjectIsCollectionContainingOnlyManagedObjects(value), @"Can only expect a connection to `nil`, a `NSManagedObject`, or a collection of `NSManagedObject` objects");
|
||||
self = [self init];
|
||||
if (self) {
|
||||
self.relationshipName = relationshipName;
|
||||
self.attributes = attributes;
|
||||
self.value = value;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)summary
|
||||
{
|
||||
return [NSString stringWithFormat:@"connect relationship '%@'", self.relationshipName];
|
||||
}
|
||||
|
||||
- (NSString *)description
|
||||
{
|
||||
NSMutableString *description = [[self summary] mutableCopy];
|
||||
if (self.attributes) [description appendFormat:@" using attributes %@", self.attributes];
|
||||
if (self.value) [description appendFormat:@" to value %@", self.value];
|
||||
return description;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user